i want to interchange the value from one selectbox to another using jquery,
MY selectbox is in the form of http://harvesthq.github.io/chosen/
Example:
say i have 2 dropdown selectbox,in first i have selected USD & on second i have selected EURO , on click of switch button both the selectbox selected value & level should interchange
http://jsfiddle.net/34kcb/ (without chosen effect, works fine)
I tried below code but its now giving me what i am looking for, so may be you can help me
$("body").on("click", "#switchid", function(){
var frm='';var to='';
frm=$("#from_currency option:selected").val();
to=$("#to_currency option:selected").val();
$("#to_currency").val(frm);
$("#from_currency").val(to);
//currencyConverter();
});
HTML code
<select name="from_currency" id="from_currency">
<option value="USD">USD : United States Dollar</option>
<option value="EUR">EUR : Euro</option>
<option value="JPY">JPY : Japanese Yen</option>
<option value="INR">INR : Indian Rupee</option>
</select>
<br/>
<select name="to_currency" id="to_currency">
<option value="EUR">EUR : Euro</option>
<option value="USD">USD : United States Dollar</option>
<option value="JPY">JPY : Japanese Yen</option>
<option value="INR">INR : Indian Rupee</option>
</select>
<br/>
<input type="button" id="switchid" value="Switch"/>
UPDATE:
In simple selectbox its working but after integrating with Choosen selectbox ,same thing is not working . any idea?