Click here to Skip to main content
15,887,453 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have some html that looks like this ( this is a small exerpt)

<td id="tdSpecVisits" style="text-align: right;">
            <asp:Label ID="lblSpecVisits" runat="server" CssClass="td-visits"></asp:Label>
        </td>
        <td id="tdSpecProg" class="prognosisContainer">
            <asp:DropDownList ID="ddlSpecProg" runat="server">
            </asp:DropDownList>
        </td>
          <td id="td-refer" style="height: 22px; display:none">
                        <asp:DropDownList ID="ddlReferSpecial" runat="server" CssClass="td-refer"   style="display:none" >
                        </asp:DropDownList>
            </td>


What I am trying to do in javascript is when lblSpecVisits has a change of value (it holds a number of visits that is changed by clicking on another control) then I want to show/hide the dropdown list ddlReferSpecial.
So when lblSpecVisits is > 0 then show the dropdown otherwise hide it.

What I have tried:

I have tried adding this code to the javascript:
lblSpecVisits.width(70).kendoTextBox({ min: 0, step: 1, format: "n0", decimals: 0, change: specRefer });
   lblSpecVisits.each(specRefer);


function specRefer() { 

    alert("specRefer");

    if (lblSpecVisits.val() > 0 && (lblGpVisits.val() > 0 || lblChiroVisits.val() > 0)) {

        alert("show");
        lblReferSpecial.show();
        $("[id$=td-refer").show();
    }
    else {

        alert("hide");
        lblReferSpecial.hide();
        ddlReferSpecial.hide();
        ddlReferSpecial.prop('selected', false);
        $("[id$=td-refer").hide();
    }
}


I have tried adding this code at different points so that as the visits change, specRefer is run but I just cant get it to work. It either goes into SpecRefer and shows the first alert but does not go into the show/hide code or it doesnt go into SpecRefer at all! Im not too familiar with javascript/jquery syntax - Im sure this is possible I just cant seem to figure it out.
Posted

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900