if CheckBox.Checked=true then TextBox should be visible
I have a list of checkboxes(Answers for a Question).
Each Checkbox has a TextBox which is invisible onFormLoad.
What I need todo:
When a user clicks on any of the Checkbox the appropriate Textbox will be Visible.
How do I do this using client side java scripting?
Please help me!
Re: if CheckBox.Checked=true then TextBox should be visible
if(!Document.GetElementById('myCheckbox').Checked)
document.form1.myTextbox.disabled=false;
The syntax might not be 100% but this should get you started.
Re: if CheckBox.Checked=true then TextBox should be visible
If they are server side controls, you can generate the javascript from your codebehind and send them to the client output using Page.RegisterClientScriptBlock.
Re: if CheckBox.Checked=true then TextBox should be visible
if(!document.getElementById('CheckBox1').Checked)
document.Form1.TextBox1.disabled=false;
The TextBox1 is enabled when the user checks the CheckBox.
sure does work, Is there another javascript method to "SHOW/HIDE" the text box?
Thanks for your help.
Re: if CheckBox.Checked=true then TextBox should be visible
Javascript isn't my thing but I don't think you can do this without DHTML though don't quote me on it.
Sorry
Re: if CheckBox.Checked=true then TextBox should be visible
Set the .style.visibility property to either "visible" or "hidden".
Re: if CheckBox.Checked=true then TextBox should be visible
mendhak, what property could you set for a DropDownList control to make it hidden?
Thanks
Re: if CheckBox.Checked=true then TextBox should be visible
The DropDownList, on the client side (which is where you want to do this from), is nothing but a <select> box. So all you need is its ID.
Let's say you have a javascript method, XYZ(), that can turn any element invisible (as shown earlier).
From your codebehind, when you are creating the call, pass it the .ClientID property of the server side control.
Code:
strJS += "XYZ('" + myDDLBox1.ClientID + "');";