Question

All,

I have the following code to update the text of a hidden field in my aspx page once a checkbox is clicked:

BiopsyDone:

< asp:CheckBox ID ="cbLiverBiopsy" runat="server" Checked="false" OnCheckedChanged="BiopsyResults_SelectedIndexChanged"/> <br/>
    < asp:HiddenField ID="hide" runat="server" Value=" " /> 

 < script>

        $(document).ready(function () {
            $("#cbLiverBiopsy").change(function () {
                $("#hide").val("The liver biopsy results were ");
            });
        });

    </script>

Once the program is run, the hidden field does not update once the checkbox is clicked. Any suggestions?

Thanks, Alan

Was it helpful?

Solution

A way to do it with ClientID

$('#<%= hide.ClientID %>').val("The liver biopsy results were ");

Then it doesn't need to be static

OTHER TIPS

Set clientidmode="static" for the hiiden input..

< asp:HiddenField ID="hide" runat="server" Value=" " clientidmode="static"/>

Access it as..

document.getelementid('hide').value="The liver biopsy results were";

or

$('#<%= hide.ClientID %>').val("The liver biopsy results were ");

For getting it by ID

HTML:

 < asp:HiddenField ID="hide" runat="server" Value=" " /> 

jQuery:

$('#<%= hide.ClientID %>').val("The liver biopsy results were ");

For getting it by Class

HTML:

 < asp:HiddenField ID="hide" class="hideClass" runat="server" Value=" " /> 

jQuery:

$('.hideClass').val("The liver biopsy results were ");
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top