473,395 Members | 2,443 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

check box question

How do I capture the click event of the check box so that every time the
box is ticked a text box is enabled, and every time the box is unticked
a text box is disabled?
Thanks,

Mike


*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Nov 18 '05 #1
3 1259
Hi mike,
you have two ways to accomplish this task.

1. Use a checkbox server control and set the autopostback property to true.
This will postback the page each time you click the checkbox and in the
click event you verify the check status and enable or disable the textbox.

2. Use a checkbox html control in combination with javascript.

Hope this helps.

Stefano Mostarda
Rome Italy

"Mike P" <mr*@telcoelectronics.co.uk> ha scritto nel messaggio
news:%2********************@TK2MSFTNGP10.phx.gbl.. .
How do I capture the click event of the check box so that every time the
box is ticked a text box is enabled, and every time the box is unticked
a text box is disabled?
Thanks,

Mike


*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!

Nov 18 '05 #2
This can easily be achieved with JavaScript, which I would recommend over
the postback method, to avoid making unnecessary server round-trips.

// Enable/Disable the textbox, when the checkbox is clicked
function ToggleTextBox(e)
{
var txtbox = document.forms[0].elements["txtbox"];
txtbox.disabled = (!e.checked);
}
</script>

<!-- Form Sample Code -->
<form>
<input name="chk" type="checkbox"
onClick="ToggleTextBox(this)">Test<br><br>
<input name="txtbox" type="text" size="50" value="blah">
</form>
Hope this helps,

Mun


"Mike P" <mr*@telcoelectronics.co.uk> wrote in message
news:%2********************@TK2MSFTNGP10.phx.gbl.. .
How do I capture the click event of the check box so that every time the
box is ticked a text box is enabled, and every time the box is unticked
a text box is disabled?
Thanks,

Mike


*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!

Nov 18 '05 #3
Thanks to both of you!
Cheers,

Mike

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Nov 18 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Mohammed Mazid | last post by:
Hi folks! Can anyone please help me with this? I am developing a Quiz program but I am stuck with "multiple answers". Basically I need some sort of code that would select multiple answers...
4
by: Mohammed Mazid | last post by:
Hi folks! Can anyone please help me with this? I am developing a Quiz program but I am stuck with "multiple answers". Basically I need some sort of code that would select multiple answers...
27
by: John Roth | last post by:
PEP 263 is marked finished in the PEP index, however I haven't seen the specified Phase 2 in the list of changes for 2.4 which is when I expected it. Did phase 2 get cancelled, or is it just not...
4
by: Jared | last post by:
Radio Button or Check Box and Event Procedures I need to insert either radio buttons or check boxes onto my form. I'm not sure which to use, or if there are other options. I am using the buttons...
0
by: Douglas Gage | last post by:
Hi every one I'm building datagrid which needs to have validiation check for each text box. Something will look like this Question Answer 1 abc validiation...
4
by: Laphan | last post by:
Hi all In my functions I'm using a double-check all the time to trap if a value has nothing in it and my question is do I need this double-check. My check line is: IF IsNull(xxx) OR...
6
by: tommaso.gastaldi | last post by:
Hi, does anybody know a speedy analog of IsNumeric() to check for strings/chars. I would like to check if an Object can be treated as a string before using a Cstr(), clearly avoiding the time...
1
by: huyuhui | last post by:
The following is a question of LOAD utility. Question: How does the DB2 enforce table check constraints for data added to table with the LOAD utility? A. With the BUILD phase of LOAD B. With the...
2
by: anget24 | last post by:
I am working on a form in access and I want my check boxes to move with the next question and eveytime i answer the question and move to the next question my check box stays checked and all I want it...
173
by: Marty James | last post by:
Howdy, I was reflecting recently on malloc. Obviously, for tiny allocations like 20 bytes to strcpy a filename or something, there's no point putting in a check on the return value of malloc....
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.