我正在尝试记录这两个对象的索引值,以便我可以循环并进行比较。此时,我有下拉列表能够返回索引值和一个单独的脚本,它将在更改下拉列表时生成索引号,但每当我尝试调整该脚本并设置变量时,我得到一个不明的变量误差。我已经尝试过调用函数来调用它,但是仍然会发生未识别的变量。有没有人有任何建议如何将两个数组的索引号记录为变量?
<div id = box1>
<form>
<select id ="bunny">
<option value = "1">United States</option>
<option value = "2">Canada</option>
<option value = "3">France</option>
<option value = "4">Hungary</option>
</select>
</form>
<br>
<form>
<select id ="bunny2">
<option value = "1">Washington, D.C.</option>
<option value = "2">Ottawa</option>
<option value = "3">Paris</option>
<option value = "4">Budapest</option>
</select>
</form>
<script type="text/javascript">
$('select').change(function(){
alert($('option:selected',$(this)).index());
});
</script>
答案 0 :(得分:0)
如果你想让它变得简单,只需自己跟踪选择。
WebClient wc = new WebClient();
wc.Headers.Add("Content-Type", "application/json; charset=utf-8");
wc.Headers.Add("Accept", "application/json");
wc.DownloadString("http://yourUrl.com/GetUserById?x=1");
够好吗?