|
-
Mar 6th, 2006, 01:21 AM
#1
Thread Starter
Member
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!
-
Mar 6th, 2006, 06:26 AM
#2
Fanatic Member
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.
-
Mar 6th, 2006, 09:53 AM
#3
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.
-
Mar 6th, 2006, 08:15 PM
#4
Thread Starter
Member
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.
-
Mar 7th, 2006, 04:56 AM
#5
Fanatic Member
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
-
Mar 7th, 2006, 05:27 AM
#6
Re: if CheckBox.Checked=true then TextBox should be visible
Set the .style.visibility property to either "visible" or "hidden".
-
Apr 24th, 2007, 01:21 PM
#7
Fanatic Member
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
-
Apr 26th, 2007, 03:51 PM
#8
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 + "');";
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|