Jump to content

Uncheck


n2963p

Recommended Posts

I'm creating a registration form that includes selecting different seminars at various times. I can get a javascript to automaticly check checkboxes. If they select a particular seminar track, I can get it to check all of the seminars for that track, but if they select two seminars at the same time, I can't get it to uncheck the box for the previously checked box.document.Register.T1A.checked="TRUE"; - This checks the boxdocument.Register.T1A.checked="FALSE"; - This also checks the boxdocument.Register.T1A.checked="0"; - This also checks the boxEverything I try turns the check box ON. How do I turn it off?Thank you in advance.

Link to comment
Share on other sites

Hmm........i don't know...that should be working. Try it with ID's instead, and at the top, use document.getElementById("t1a").checked=false:) ~Chocolate570

Link to comment
Share on other sites

You're just changing the value of the checked attribute. The only possible value for that attribute is "checked", so to check it you should use this:document.Register.T1A.checked="checked"The reason the others worked is because only the attribute is necessary (value is useless) in HTML4. To uncheck the box, you need to tell it to drop the attribute completely somehow... Dunno how, sorry. =/

Link to comment
Share on other sites

Test this Function--------------------function fn_check(){ for (i=0 ; i<document.f1.elements.length; i++) { if (document.f1.elements.type == "checkbox") { document.f1.elements.checked = true; } }}where f1 is the FORM namethe beauty of this :- first it will get all the elements in form and if that element type is checkbox then it will check. For uncheck write another function called fn_uncheck and change (document.f1.elements.checked = true;) to (document.f1.elements.checked = false;). it will work.Luv,Vamsy.

Link to comment
Share on other sites

Thanks to everyone. I have my problem solved. :) No matter what value I assigned to the checked property, it always checked the box. I tried "FALSE", "false", "OFF", "off", "0", & "unchecked". They all turned the check box ON.What I came up with is this: if (document.Register.T2B.checked) { document.Register.T2B.click(); }Basicly, I check to see if the box is checked, and if it is, I issue the click() command to uncheck it.

Link to comment
Share on other sites

Now listen everyone!This is a perfect example of what I am going to say here..Some properties differ in the HTML DOM from what the value has in HTML!!!When it does not work for you, test it like this, and it works like heaven!

java script: alert( document.A_Certain_Element.style.display)
The blue is to give you an alert. The green is to get the correct item you want to know something from, and the red is what you want to know of it. You can even apply the red a value, by adding after the red something like ="block"Edit: This can be done with every HTML DOM object :)This way you can supply yourself with some information about a document currently loaded into the browser window, without messingup the sourcecode. It gives you an alert with the appropriate value, that IS used, not to be confused with the value used in HTML.:):( Edited by Dan The Prof
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...