$event = $fieldset->addField('parent_id', 'select', array(
'label' => Mage::helper('gallery')->__('Parent'),
'required' => true,
'name'=>'parent_id',
'values'=>$ac,
'onchange'=>'CheckSelectedItem()',
));
$event->setAfterElementHtml('<script>
function CheckSelectedItem()
{
var ddllist= window.document.getElementById("parent_id");
var itemName= ddllist.options[ddllist.selectedIndex].value;
"gallerydata.php" というルート フォルダにあるファイルに対して、form.php で ajax 呼び出しを行う方法。バックエンドから画像をアップロードするための「ギャラリー」という拡張機能があります。そのため、そのファイル「gallerydata.php」を呼び出すajaxを使用して、ドロップダウンからアーティストのIDを取得したいと考えています。
if(window.XMLHttpRequest)
{// code for IE7+, Firefox, Chrome, Opera, Safari
xmlhttp=new XMLHttpRequest();
xmlhttp1=new XMLHttpRequest();
}
else
{// code for IE6, IE5
xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
xmlhttp1=new ActiveXObject("Microsoft.XMLHTTP");
}
xmlhttp.onreadystatechange=function()
{
if (xmlhttp.readyState==4 && xmlhttp.status==200)
{
alert(xmlhttp.responseText);
}
}
xmlhttp.open("GET","http://122.170.97.189:81/electriccityusa/gallerydata.php?q="+itemName,true);
}
</script>');