<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 单词),当它们加载到当前页面时,没有空格的值用作用户的 id 以进行 onchange 操作,然后稍后对其进行格式化。非常感谢你:
<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>