<script type="text/javascript">
var CountryVal;
var StateVal;
$(document).ready(function(){
$('#ItemCountry').change(function(){
CountryVal = this.value; // value of the select element
$("#StateFeeder").html('<img src="/images/mapCountry/AU/ajax-loader.gif" class="IMG-Loading" />');
$('#StateFeeder').load('/StateFeeder/StateFeeder-Buy.html #StateFeeder-'+CountryVal, function(){
$('#ItemState').change(function(){
StateVal = this.value; // value of the select element
$("#CityFeeder").html('<img src="/images/mapCountry/AU/ajax-loader.gif" class="IMG-Loading" />');
$('#CityFeeder').load('/Country/'+CountryVal+'/_'+CountryVal+'_suburbs.html #Suburbs-'+StateVal, function(){
$('#CityFeeder select').attr('size', '5');
$('#CityFeeder select').change(function(){
this.form['CAT_Custom_221342'].value=$(this).val();
});
});
})
});
});
});
</script>
上面的 Jquery 将从其他页面加载下拉菜单到当前页面,并在用户进行选择时将值传递到另一个输入字段。问题是,从远程页面中的#StateFeeder 获取的选项值包含以下格式:
<option value="Kabardino-BalkarRepublic">Kabardino-Balkar Republic</option>
<option value="Karachay-CherkessRepublic">Karachay-Cherkess Republic</option>
<option value="KareliaRepublic">Karelia Republic</option>
<option value="KomiRepublic">Komi Republic</option>
<option value="MariElRepublic">Mari El Republic</option>
<option value="MordoviaRepublic">Mordovia Republic</option>
上面的值是不间断的大写单词,我希望它们在加载到当前页面时在大写单词之间使用空格进行格式化(请保留“-”btw单词),特别关注#ItemState部分:当城市值被加载到#ItemState 菜单中,例如“KareliaRepublic” 值(没有空格“KareliaRepublic”)被视为 id,以便可以正确加载远程菜单,请格式化它直到此加载过程完成然后处理添加空间操作。非常感谢你:
<option value="Kabardino-Balkar Republic">Kabardino-Balkar Republic</option>
<option value="Karachay-Cherkess Republic">Karachay-Cherkess Republic</option>
<option value="Karelia Republic">Karelia Republic</option>
<option value="Komi Republic">Komi Republic</option>
<option value="Mari El Republic">Mari El Republic</option>
<option value="Mordovia Republic">Mordovia Republic</option>