Connecting Tech Pros Worldwide Forums | Help | Site Map

check box question

Mike P
Guest
 
Posts: n/a
#1: Nov 18 '05
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!

stefano mostarda
Guest
 
Posts: n/a
#2: Nov 18 '05

re: check box question


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" <mrp@telcoelectronics.co.uk> ha scritto nel messaggio
news:%239%23ss%23PrDHA.2416@TK2MSFTNGP10.phx.gbl.. .[color=blue]
> 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![/color]


Munsifali Rashid
Guest
 
Posts: n/a
#3: Nov 18 '05

re: check box question


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" <mrp@telcoelectronics.co.uk> wrote in message
news:%239%23ss%23PrDHA.2416@TK2MSFTNGP10.phx.gbl.. .[color=blue]
> 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![/color]


Mike P
Guest
 
Posts: n/a
#4: Nov 18 '05

re: check box question


Thanks to both of you!


Cheers,

Mike



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