Reputation: 13
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
Upvotes: 1
Views: 588
Reputation: 931
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 ");
Upvotes: 0
Reputation: 1838
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 ");
Upvotes: 1
Reputation: 494
A way to do it with ClientID
$('#<%= hide.ClientID %>').val("The liver biopsy results were ");
Then it doesn't need to be static
Upvotes: 5