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

Resetting checkbox 1

Status
Not open for further replies.

amethystct

Programmer
Jan 26, 2004
21
FR
I have a checkbox. Onclick it opens a new page. I don't want the field to stay checked though. I was going to reset the form using the name but I don't have it. The name is set to the index value of the row I'm showing.

<TD ALIGN=&quot;CENTER&quot;><INPUT TYPE=&quot;checkbox&quot; NAME=&quot;param:index&quot; VALUE=&quot;moreInfo&quot; onClick=&quot;showInfo(this);&quot;></TD>

How do I reset this checkbox to unchecked in the function?

Thanks! :)
 
Is it the only checkbox on the page? If so then there's a simple solution. Take note that this will uncheck all boxes on your page (which might come in handy, never know)
Code:
function uncheckBoxes() {
   var boxes = document.getElementsByTagName(&quot;checkbox&quot;);
   for (j = 0; j < boxes.length; j++) {
      boxes[j].checked = false;
   }
}

-kaht

banghead.gif
 
Kaht,

Nope, I have another checkbox on the page. This is still good info though! Thanks.

 
inside the function showInfo(), add this:

function showInfo(whateverThisVarIsCalled) {
// ...existing code...

whateverThisVarIsCalled.checked = false;
}

=========================================================
-jeff
try { succeed(); } catch(E) { tryAgain(); }
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top