html
<span id="mes015[1000]" style="font-size:12px;color:#0066FF "><a href="javascript:void(0)"
onclick="xajax_keyword_select03('select015[1000]','SELECT invma01,invma02,invma03 FROM invma ORDER BY invma01 ASC','品號','品名','規格','invma01','invma02','invma03','invsd01[1000]','mes01[1000]','','value','innerHTML','','mes015[1000]','xajax_checkinvmj04(\'invsd01[1000]\',document.getElementById(\'invsd01[1000]\').value,\'mes01[1000]\',\'mes02[1000]\',\'mes39[1000]\',\'mes04[1000]\',\'invsd09[1000]\')')"><img src="../public/image/set-3/search.gif" alt="查詢全部品號" width="16" height="16" border="0" /></a> </span>
xajax
function keyword_select03($selectname,$sql01,$key_text_name01,$key_text_name02,$key_text_name03,$keycol01,$keycol02,$keycol03,$keyloc01,$keyloc02,$keyloc03,$keyattribute01,$keyattribute02,$keyattribute03,$mes01,$xajaxtext)//
{
require('../Connections/conn_xxx.php');
mysql_select_db($database_conn_xxx, $conn_xxx);
$query_keyword_select = $sql01;
$keyword_select = mysql_query($query_keyword_select, $conn_xxx) or die(mysql_error());
$row_keyword_select = mysql_fetch_assoc($keyword_select);
$totalRows_keyword_select = mysql_num_rows($keyword_select);
$objResponse = new xajaxResponse();
do{
if($keycol01!=NULL)$body00 ='『' . $row_keyword_select[$keycol01] . '』';
if($keycol02!=NULL)$body00 .='『' . $row_keyword_select[$keycol02] . '』';
if($keycol03!=NULL)$body00 .='『' . $row_keyword_select[$keycol03] . '』';
$body01 .= "<option value=\"{$row_keyword_select[$keycol01]}\"value2=\"{$row_keyword_select[$keycol02]}\"value3=\"{$row_keyword_select[$keycol03]}\">{$body00}</option>";
} while ($row_keyword_select = mysql_fetch_assoc($keyword_select));
$rows = mysql_num_rows($keyword_select);
if($rows > 0) {
mysql_data_seek($keyword_select, 0);
$row_keyword_select = mysql_fetch_assoc($keyword_select);
}
$body02="<select name=\"{$selectname}\" onchange=\"";
if($keyloc01!=NULL)$body02 .= "document.getElementById('{$keyloc01}').{$keyattribute01} = this.options[this.selectedIndex].value;";
if($keyloc02!=NULL)$body02 .= "document.getElementById('{$keyloc02}').{$keyattribute02} = this.options[this.selectedIndex].value2;";
if($keyloc03!=NULL)$body02 .= "document.getElementById('{$keyloc03}').{$keyattribute03} = this.options[this.selectedIndex].value3;";
$body02 .= "document.getElementById('{$keyloc01}').select();";
$body02 .= $xajaxtext;
if($key_text_name01!=NULL)$body03 ='『' . $key_text_name01 . '』';
if($key_text_name02!=NULL)$body03 .='『' . $key_text_name02 . '』';
if($key_text_name03!=NULL)$body03 .='『' . $key_text_name03 . '』';
$body02.="\"><option value=\"\"value2=\"\"value3=\"\">{$body03}</option>{$body01}</select>";
$objResponse->addAssign($mes01,"innerHTML",$body02);
return $objResponse;
}
這是用來產生下拉式選單的xajax程式,可以依你所設的sql語句,及相關欄位的欄名來運作!
不過有個小缺點,在firefox中value2, value3其onchange不適用,ie6則正常
即在select中
<option value=''a' value2='b' value3='c'>...</option>
順便問一下有人知道怎麼寫讓firefox中也正常嗎?
ps:敝人是覺得也許再設另一個xajax function在select的onchange中…