File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes HTML, CSS and JavaScript and the fly likes Clearing checkboxes Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


Win a copy of Practical Unit Testing with TestNG and Mockito this week in the Testing forum!
JavaRanch » Java Forums » Engineering » HTML, CSS and JavaScript
Reply Bookmark "Clearing checkboxes" Watch "Clearing checkboxes" New topic
Author

Clearing checkboxes

Chris Garrison
Ranch Hand

Joined: Jun 13, 2002
Posts: 44
I have a form that contains several radio buttons and checkboxes that correspond with the radios.

For instance:

(radio) Supreme Pizza
<checkbox> no onions <checkbox> no sausage <checkbox> no cheese ....
(radio) Meat Lovers Pizza
<checkbox> no sausage <checkbox> no canadian bacon...

and so on.

You select Supreme Pizza initially and select the "no onions" chechbox.

But then you change your mind and click the MeatLovers. The radio button is reset correctly but how can I automatically clear the "no onions" checkbox from the Supreme Pizza?

Thanks for you help.


May the force be with you, always.
Eric Pascarello
author
Rancher

Joined: Nov 08, 2001
Posts: 15003
basically you are going to have to make a function to clear all of the resets for all check boxes on the page when they click the button.

document.FormName.checkboxname.checked=false;

basically you can make a look and look through each one

document.FormName[checkboxNameVariable].checked = false;

Need more help just give a hollar...

Eric
Chris Garrison
Ranch Hand

Joined: Jun 13, 2002
Posts: 44
Thanks Eric,

I thought I could figure it out but I'm stumped (and new to script)

here is some code -i'm sure its something simple.





As I understand it - when you click on the radio button (named "item") it runs the ClearCheckBoxes fuction - which should set all checkboxes (check1, check2 ...) to off.

Why isn't it working?

NOTE - i cut a lot of table formatting stuff out so you wouldn't have to sift through it.

Thanks

[ May 26, 2004: Message edited by: Chris Garrison ]
[ May 26, 2004: Message edited by: Chris Garrison ]
Eric Pascarello
author
Rancher

Joined: Nov 08, 2001
Posts: 15003
your form name is order

so

An easier way to do it would be


See if that helps you out.
Eric
Chris Garrison
Ranch Hand

Joined: Jun 13, 2002
Posts: 44
I think I'm close but I keep getting an error "document.order.a'is null ornot an object". What am I doing wrong?



Thanks for your help

[ June 01, 2004: Message edited by: Chris Garrison ]
[ June 01, 2004: Message edited by: Chris Garrison ]
Eric Pascarello
author
Rancher

Joined: Nov 08, 2001
Posts: 15003
add quotes around all of the words in your array a[X]="blah";

also change this
document.order.a[yy].checked=false;
to
document.order[a[yy]].checked=false;
Chris Garrison
Ranch Hand

Joined: Jun 13, 2002
Posts: 44
Excellent!!!

Thanks!!!

Halleluia!!
 
IntelliJ Java IDE
 
subject: Clearing checkboxes
 
Threads others viewed
OnClick - trigger Reset button?
An impossible question
problem with form submission
checkboxes
Using XSL to Render and Toggle Selected Radio Button or Selected Checkboxes
developer file tools

cast iron skillet 49er

more from paul wheaton's glorious empire of web junk: cast iron skillet diatomaceous earth rocket mass heater sepp holzer raised garden beds raising chickens lawn care CFL flea control missoula heat permaculture