Reputation: 24052
if ($("#IndicationCalculatorGroupId option:selected").text() == 'Create a New Group')
{
$("#newGroupNameRow").show();
}
$("#IndicationCalculatorGroupId").change(function() {
if ($("#IndicationCalculatorGroupId option:selected").text() == 'Create a New Group')
{
$("#newGroupNameRow").show();
}
else{
$("#IndicationCalculatorNewGroupName").val('');
$("#newGroupNameRow").hide();
}
});
I have that in my document ready. Basically when the page loads, I want to check to see if the one dropdown has a certain value, and if it does, show a certain div. The onChange() events work correctly, so I know that check is done properly, it just doesn't seem to work onDocumentReady. The div won't show().
Am I doing anything wrong?
Upvotes: 1
Views: 212
Reputation: 3526
I think you may miss :
To set the default selected value of "IndicationCalculatorGroupId" and you need to call
$("#IndicationCalculatorGroupId").change()
after your change function to execute your login in change event.
Upvotes: 2
Reputation: 7360
I tried your code here http://jsfiddle.net/DkZpB/ and it seems to work ok. The one thing I did notice was that when I used an inline style on <div id="newGroupNameRow">
, the .show()
method didn't do anything. I had to set display:none
via CSS instead, or call .hide()
as the first thing on $(document).ready()
.
Upvotes: 0