关于下拉框调用函数问题? 楼主的函数是php服务端的,onclick是客户端调的js,当然不可能这样调起来啊!正常的做法是客户端的js里封装一个ajax的方法,用来触发服务端的php代码。 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 汗你错的太厉害了啊。。你的函数都写错了。你这完全把php和js搞混了吧。<?function displaytr(){if(form.law_table.value==1){$sql="select * from table where id=8";$res=mysql_query($sql);$row=mysql_fetch_array($res);print("<script>alert(\"$row[name]\")</script>");}else{print("<script>alert(\"test\")</script>");}}?>你这到底是什么的函数啊?如果是一个js函数,js外面声明<script language='javascript'>function xxxx(){}</script>而你这个呢?function xxx(){<script>alert();</script>}这也错的太离谱了 当然没反应啦,ONchange掉用的应该是javascript函数呀,怎么会是PHP函数呢? 哦,我明白了,但是在js中,我怎么才能把mysql中的数据调出来呢? 这个乱是乱是点,不过可以用。LZ不妨看看。===============================================<?$query3="select * from product where p_ifshow<>8 order by p_order asc "; $result3=mysql_query($query3);$num3=mysql_num_rows($result3);?><script language = "JavaScript">var onecount;subcat = new Array(); <? for($count=1;$count<=$num3;$count++){ $row3 = mysql_fetch_array($result3); $id=$row3["id"]; $p_bigclassid=$row3["p_bigclassid"]; $p_title=$row3["p_title"]; ?>subcat[<? echo $count;?>] = new Array("<? echo $p_title; ?>","<? echo $p_bigclassid; ?>","<? echo $p_title; ?>"); <? } ?>onecount=<? echo $count;?>;function changelocation(locationid) { document.myform.SmallClassName.length = 1; var locationid=locationid; var i; //alert (locationid); for (i=1;i < onecount; i++) { if (subcat[i][1] == locationid) { //alert (onecount+subcat[i][1]); document.myform.SmallClassName.options[document.myform.SmallClassName.length] = new Option(subcat[i][0], subcat[i][2]); } } } </script><select name="BigClassName" onChange="changelocation(document.myform.BigClassName.options[document.myform.BigClassName.selectedIndex].value)"> <option value=0>aa</option></select><select name="SmallClassName"> <option value="不指定小类>bb</option> </select> XAMPP中apache无法启动问题 分页 新手请教:访问类数组的问题 请问我该怎样储存模板 数据搜索后php如何返回xml php+Excel在线等!!!!!! 救助PHP取客户端IP的方法 请问在php文件内指令执行另一个php文件的函数 如何对TEXT类型字段的分次处理 一个在php3下可运行但在php4运行有问题 php搜索问题请教 时差 及 数据库查询问题..
function displaytr()
{
if(form.law_table.value==1)
{
$sql="select * from table where id=8";
$res=mysql_query($sql);
$row=mysql_fetch_array($res);
print("<script>alert(\"$row[name]\")</script>");
}
else
{
print("<script>alert(\"test\")</script>");
}
}
?>你这到底是什么的函数啊?如果是一个js函数,js外面声明
<script language='javascript'>
function xxxx()
{
}
</script>
而你这个呢?function xxx(){<script>alert();</script>
}这也错的太离谱了
但是在js中,我怎么才能把mysql中的数据调出来呢?
===============================================
<?
$query3="select * from product where p_ifshow<>8 order by p_order asc ";
$result3=mysql_query($query3);
$num3=mysql_num_rows($result3);
?>
<script language = "JavaScript">
var onecount;
subcat = new Array();
<? for($count=1;$count<=$num3;$count++){
$row3 = mysql_fetch_array($result3);
$id=$row3["id"];
$p_bigclassid=$row3["p_bigclassid"];
$p_title=$row3["p_title"];
?>
subcat[<? echo $count;?>] = new Array("<? echo $p_title; ?>","<? echo $p_bigclassid; ?>","<? echo $p_title; ?>");
<? } ?>
onecount=<? echo $count;?>;function changelocation(locationid)
{
document.myform.SmallClassName.length = 1;
var locationid=locationid;
var i;
//alert (locationid);
for (i=1;i < onecount; i++)
{
if (subcat[i][1] == locationid)
{
//alert (onecount+subcat[i][1]);
document.myform.SmallClassName.options[document.myform.SmallClassName.length] = new Option(subcat[i][0], subcat[i][2]);
}
}
}
</script><select name="BigClassName" onChange="changelocation(document.myform.BigClassName.options[document.myform.BigClassName.selectedIndex].value)">
<option value=0>aa</option>
</select><select name="SmallClassName">
<option value="不指定小类>bb</option>
</select>