Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/423.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/mysql/62.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
javascript onclick事件在具有SQL驱动数据的Chrome中不起作用_Javascript_Mysql_Google Chrome - Fatal编程技术网

javascript onclick事件在具有SQL驱动数据的Chrome中不起作用

javascript onclick事件在具有SQL驱动数据的Chrome中不起作用,javascript,mysql,google-chrome,Javascript,Mysql,Google Chrome,选项s不支持onclick。您应该使用select的onchange。该值可以存储在属性中,如数据县(数据-属性可用于存储元素上的数据): Hi,您能在问题中包含php生成的实际html输出吗?使复制和粘贴更容易,并能更快地获得帮助。什么类型的元素是#distr?以下是Chrome 1 Decemberrie-IF AUGUST-23 CT ABRUD-AB中输出的代码。。。谢谢,它成功了,只是活动应该是onChange而不是onSelect。只有一次改变起了作用。再次感谢。 <sele

选项
s不支持
onclick
。您应该使用
select
onchange
。该值可以存储在属性中,如
数据县
数据-
属性可用于存储元素上的数据):



Hi,您能在问题中包含php生成的实际html输出吗?使复制和粘贴更容易,并能更快地获得帮助。什么类型的元素是
#distr
?以下是Chrome 1 Decemberrie-IF AUGUST-23 CT ABRUD-AB中输出的代码。。。谢谢,它成功了,只是活动应该是onChange而不是onSelect。只有一次改变起了作用。再次感谢。
<select id='city' name='city' > 
<?php
$dbcon = mysql_connect($host, $username, $password);
mysql_select_db($db_name,$dbcon) or die( "Unable to select database");
$city_query = "SELECT city,county FROM citycatalog order by city asc";
$city_res = mysql_query($city_query);
$city_num = mysql_num_rows($city_res);
$i=0;
while($i < $city_num){
$city_val = mysql_result($city_res,$i,'city');
$county_val = mysql_result($city_res,$i,'county');
echo "<option value=\"$city_val\" onClick=\"document.getElementById('county').value = '$county_val'\" >$city_val</option>";
$i++;
};
?>
</select>
<input type="text" id='county' name='county' />
<select id='city' name='city' onchange="document.getElementById('county').value = this.options[this.selectedIndex].getAttribute('data-county');"> 
<?php
$dbcon = mysql_connect($host, $username, $password);
mysql_select_db($db_name,$dbcon) or die( "Unable to select database");
$city_query = "SELECT city,county FROM citycatalog order by city asc";
$city_res = mysql_query($city_query);
$city_num = mysql_num_rows($city_res);
$i=0;
while($i < $city_num){
$city_val = mysql_result($city_res,$i,'city');
$county_val = mysql_result($city_res,$i,'county');
echo "<option value=\"$city_val\" data-county=\"$county_val\" >$city_val</option>";
$i++;
};
?>
</select>
<input type="text" id='county' name='county' />