I am trying to show a div based on a drop down selection. With some drop downs, I have multiple "values" and this is where I have the problem. How can I have the javascript only see the string in the "VALUE" until the comma.
This code works if I change
value = 'ABCD,asdf;
to
value = 'ABCD'
<script>
$(document).ready(function(){
$('#test').on('change', function() {
if ( this.value == 'ABCD')
{
$("#rrrr").show();
}
else
{
$("#rrrr").hide();
}
});
})
</script>
<select id='test' name = 'test'>
<option value = '123'>hide div</option>
<option value = 'ABCD,asdf'>display div</option>
</select>
<input type='submit' name = 'submit' value='Apply'>
<div style='display:none;' id='rrrr'>
display this section
</div>
Ho can I use value = 'ABCD,asdf' so that I can show the div when teh value contains the string until the comma? I need to have 2 strings in the value