Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

checkbox check using javascript..

Status
Not open for further replies.

jagprg

Programmer
Jun 16, 2005
11
US
hi,

I am using <html:checkbox....tag for my checkbox, I get the value of it true or false from a Object dynamically..shown below

Code:
<html:checkbox property="trafficSignals" disabled="false" value='<%= home.getTrafficSignals() ? "true" : "false" %>'/>&nbsp;&nbsp;Traffic Signals<br/>

I am able to set its value as true or false, but not able to show it on the jsp as checked, Could anyone tell how I can show it as checked using javascript.

thanks in advance.
 
Hi!
Code:
document.forms['formname'].elements['checkboxname'].checked = true;

or

document.forms['formname'].elements['checkboxname'].checked = false;

[cheers]
Cheers!
Laura
 
Do you really want to set the VALUE of the checkbox depending on the value of that variable?

It seems to me you should be leaving the value alone (set at "true") and setting whether or not the checkbox is checked depending on the value of that variable.

For that you don't need any javascript, just do it in you server-side code like this:
Code:
<html:checkbox property="trafficSignals" disabled="false" value='true' <%= home.getTrafficSignals() ? "checked" : "" %>'/>&nbsp;&nbsp;Traffic Signals<br/>

Tracy Dryden

Meddle not in the affairs of dragons,
For you are crunchy, and good with mustard. [dragon]
 
Hi Tracy,
I tried that but, the check box disappeared next to the text(I could see only the text but not checkbox). So, I decided to use javascript.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top