Here is my code.
<script type="text/javascript">
function showDiv(divID,val) {
var text= val.value;
alert(text);
}
</script>
Mouse:<select onChange="showDiv('#mouse',this);">
<option value="">Select Mouse Type</option>
<option value="{'text':'Normal','id':'normalMouse'}">Normal</option>
<option value="{'text':'Gaming','id':'gamingMouse'}">Gaming</option>
</select>
The output is:
{'text':'Normal','id':'normalMouse'}
But The output should be 'normal' only. That means I want to access to those values separately.How to do that?
text = JSON.parse(text); alert(text.text);