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 SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to check / uncheck the checkbox ...

Status
Not open for further replies.

msng

Programmer
Oct 14, 2003
27
0
0
US
I have defined the checkbox as follows in my form:

<tr align="left">
<th width="15%" align="right">Int'l Ind</th>
<td>
<input type="checkbox" name="intl_ind" id="intl_ind">
</td>
</tr>

In my javascript, I am doing as follows:

var ind=customerInfo[ind].intl_ind;
if (ind == '1')
{
document.customeraddform.intl_ind.checked = TRUE;
}
/*if intl_ind is 0, then the checkbox for intl_ind should be unchecked*/
if (ind == '0')
{
document.customeraddform.intl_ind.checked = FALSE;
}

Howeverm, this setting TRUE and FALSE does not seem to be working.

Please let me know what am I doing wrong here. Thanks.
 
how are you calling the javascript function that you just created??? can we see the code??

"Behind every great fortune there lies a great crime", Honore De Balzac
 
U can't directly check or uncheck the checkbox just using javascript..
one way to use achieve this is get the default value by self posting and use that to check or uncheck..

<input type="checkbox" name="intl_ind" onClick="CheckSelection()"
<cfif isDefined("form.intl_ind")>Checked
<cfelse>unchecked
</cfif> >

u use form.intl_ind if u use "post" ..
if u r using get use url.intl_ind..

javascript to post and

function CheckSelection()
{
document.customeraddform.method = "post";
document.customeraddform.action = 'YourPage.cfm';
document.customeraddform.submit();
}

goodluck...
 
Sure you can! Use a fuction like the following:

Function ClearCheckboxes()
{
formName.checkboxName1.checked = false;
formName.checkboxName2.checked = false;
formName.checkboxName3.checked = false;
formName.checkboxName4.checked = false;
}

don't make the following mistake:
formName.checkboxName1.checked = "false";

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top