So I have a drop-down list and a text-box:
<table>
<tr>
<td>Group Name: </td>
<td><%= Html.DropDownListFor(m => m.IndicationCalculatorGroupId, DropDownData.IndicationsGroup(SessionManager.Company.EntityID, ICConstants.IndicationsCalculatorGroupType), "", new { propertyName = "IndicationCalculatorGroupId", onchange = "UpdateField(this, false);GroupNameChange();" })%></td>
</tr>
<tr id="newGroupNameRow">
<td>New Group Name: </td>
<td><%= Html.TextBoxFor(m => m.IndicationCalculatorNewGroupName, new { @class = "economicTextBox", propertyName = "IndicationCalculatorNewGroupName", onchange = "UpdateField(this);" })%></td>
</tr>
</table>
I have JQuery on the page that shows/hides the text-box based on the drop-down selection.
function GroupNameChange()
{
$("#IndicationCalculatorGroupId").change(function() {
if ($("#IndicationCalculatorGroupId option:selected").text() == 'Create a New Group')
{
$("#newGroupNameRow").show();
}
else{
$("#IndicationCalculatorNewGroupName").val('');
$("#newGroupNameRow").hide();
}
});
}
But it seems that the first time you change the drop-down to "Create a New Group", the text-box doesn't show or do anything, it's only when you select some other value and THEN select "Create a New Group" does the code start to work.
What's not wired up correctly?