【发布时间】:2012-06-12 13:03:09
【问题描述】:
在 onchange 事件在 jquery.selectbox-05 中不起作用,我使用两个下拉框,一个用于国家另一个州,如果我选择国家,该州将自动拾取它在正常的 php 下拉列表中工作,但我使用此代码jquery.selectbox 它不起作用任何人都会帮助我
这是我的代码
<script type="text/javascript" src="scripts/jquery.selectbox-0.5.js"></script>
<script type= "text/javascript" src = "scripts/countries2.js"></script>
$(document).ready(function(){
$('.selectBoxMedium').selectboxMedium();
$('.selectBoxSmall').selectboxSmall();
$('.selectBoxSmallest').selectboxSmallest();
$('.selectBox').selectbox();
$(document).pngFix();
});
<p class="formInput formSelectBox">
<select onchange="print_state1('state',this.selectedIndex);" id="country" class= "selectBox data" name ="country"></select>
</p>
<p class="formInput formSelectBox">
<select name ="state" id ="state" class="selectBox"></select>
<script language="javascript">print_country1("country");</script>
</p>
Javascript 函数:
function print_country1(country_id) {
// given the id of the <select> tag as function argument, it inserts <option> tags
var option_str = document.getElementById(country_id);
var x, i=0;
for(x in country_arr){
option_str.options[i++] = new Option(country_arr[x],country_arr[x]);
}
}
function print_state1(state_id, state_index) {
var option_str = document.getElementById(state_id);
var x, i=0;
state_index++;
var state_arr = s_a[state_index].split("|");
for(x in state_arr) {
option_str.options[i++] = new Option(state_arr[x],state_arr[x]);
}
}
【问题讨论】:
-
代码在哪里?粘贴您的代码(HTML 和 JavaScript):D
-
粘贴函数
print_state1和print_country1的代码?函数print_country1被正确执行了吗? -
function print_country1(country_id){ // 给定
-
我从这个站点获取代码bdhacker.wordpress.com/2009/11/21/…
-
@vicky,你从哪里得到选择框插件?
标签: php jquery jquery-plugins