<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>
The Jquery above will load dropdown menu from other page into current page and pass value into another input field when user makes selection. The problem is, the option value taken from the #StateFeeder in remote page contains the below format:
<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>
the values above are nonstop capitalized words and I want them to be formated with spaces in between capital words like below (plz keep the “-” btw words)when they are loaded into the current page, special concern in #ItemState part: when city values are loaded into #ItemState menu,e.g. “KareliaRepublic” the values(without space “KareliaRepublic”) is considered as id so that remote menu can be properly loaded, please format it until this load process completed then process the add space action. thank you very much:
<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>
This should work: