我有一个包含国家/地区列表的js文件,然后还为用户提供该国家/地区内的州/地区选择。用户拥有他们在注册时提供给我们的国家和州。我希望能够在他们转到此页面时将其显示为默认值,但我不确定如何实现这一点。这就是我所拥有的:
<?
//COUNTRY AND STATE DATA COME FROM A PREPARED PDO STATEMENT.
$usercountry = $rows['country'];
$userstate = $rows['state'];
?>
<script type= "text/javascript" src = "countries.js"></script>
Country: <select onchange="print_state('state1',this.selectedIndex);" id="country1" name = "country">
District/State: <select name ="state" id = "state1"></select>
<script language="javascript">print_country("country1");</script>
您可以通过以下链接查看JS文件:http://jsfiddle.net/mjufa/
如何将php值设为默认值?