/ Published in: jQuery
Gets value of option from ” - “ and inserts it into specified input
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
//usage jQuery(document).ready(function() { $("select#yourselect").change(onSelectChange); }); //function function onSelectChange(){ var selected = $("select#yourselect option:selected"); var output = ""; if(selected.val() != 0){ output = selected.text(result); var str = selected.text(); var result = str.substring(str.indexOf(" - ") + 3,str.length); } $("input#yourinput").val(result); }