Php while循环中的jQuery下拉列表
我想在while循环中使用jQuery下拉列表。但在中,只在第一行显示jQuery下拉列表。对于行的其余部分,它没有调用jQuery下拉列表函数。我有没有办法动态调用jQuery函数Php while循环中的jQuery下拉列表,php,jquery,html-select,Php,Jquery,Html Select,我想在while循环中使用jQuery下拉列表。但在中,只在第一行显示jQuery下拉列表。对于行的其余部分,它没有调用jQuery下拉列表函数。我有没有办法动态调用jQuery函数 //This is the java script for calling the dropdown list <meta http-equiv="refresh" content="600" > <!-- Apply dropdown check list to the
//This is the java script for calling the dropdown list
<meta http-equiv="refresh" content="600" >
<!-- Apply dropdown check list to the selected items -->
<script type="text/javascript">
$(document).ready(function(){$("#s1").dropdownchecklist( { width: 300 } );});
</script>
//this is the while loop which display the list of row with drop down checklist in it
//display the list of rows
while($rows = mysql_fetch_array($query)){
<select id="s1" multiple="multiple" >
<option value=""></option>
<?php while($rowsakh= mysql_fetch_array($resultakh)) { ?>
<option value='<?php echo $rowsakh['diet_id']; ?>'><?php echo $rowsakh['diet_name']; ?></option> <?php } ?>
</select>
}//end while loop
//这是用于调用下拉列表的java脚本
$(document).ready(function(){$(“#s1”).dropdownschecklist({width:300});});
//这是while循环,它显示行列表,其中包含下拉列表
//显示行列表
while($rows=mysql\u fetch\u array($query)){
}//边结束边循环
如果我试图使
id=“s1”
成为一个动态变量,它在每个循环中都会增加。是否有任何方法可以使id=“s1”
动态化,或者让我使用语法来执行此操作。如果希望id
像id=“s1”
id=“s2”
一样动态化,可以通过定义一个值为1的变量,每次看起来都将变量增加1,这样代码就会是这样的,
$i = 1;
while($rows = mysql_fetch_array($query)){
<select id="s<?php echo $i; ?>" multiple="multiple" >
<option value=""></option>
<?php while($rowsakh= mysql_fetch_array($resultakh)) { ?>
<option value='<?php echo $rowsakh['diet_id']; ?>'><?php echo $rowsakh['diet_name']; ?></option> <?php } ?>
</select>
$i++;
}
$i=1;
while($rows=mysql\u fetch\u array($query)){
$i++;
}
什么是您的$query
?感谢您的帮助。我能够解决我的问题。结果证明,我使用了错误的语法在Java脚本中传递php值。