Page 2 of 2

Posted: Thu Sep 15, 2005 9:02 am
by CoderGoblin
Try without the . between the elements and [NAME].

Code: Select all

if (document.elements[NAME][i].checked==true)

Posted: Thu Sep 15, 2005 9:10 am
by pilau
CoderGoblin wrote:Try without the . between the elements and [NAME].

Code: Select all

if (document.elements[NAME][i].checked==true)
It then says:

Error: document.elements has no properties
Source File: http://www.wormiverse.com/rewclan/calendar.php
Line: 21

Posted: Thu Sep 15, 2005 9:15 am
by raghavan20
may be this does wot you are looking for.

Code: Select all

<script>
	function getStatus(name){
		var inps = document.getElementsByName(name); 
		//alert(inps);
		//alert(inps.length);
		var i = 0;
		var checked;
		for(i = 0; i < inps.length; i++){
			//alert(inps[i].value);
			//alert(inps[i].name);
			if(inps[i].value == "main"){
				var checked = inps[i].checked;
				alert("got the value main");
			}
			//alert(inps[i].checked);
			//alert(inps[i].type);
		}

		for(i = 0; i < inps.length; i++){
			inps[i].checked = checked;
		}
		
		
	}
</script>
january <input type='checkbox' value = 'main' name = 'January' onblur='getStatus("January")' />
january item 1<input type='checkbox' value = '23' name = 'January' onblur='getStatus("January")' />
january item 2<input type='checkbox' value = '2' name = 'January' onblur='getStatus("January")' />
january item 3<input type='checkbox' value = '30' name = 'January' onblur='getStatus("January")' />
january item 4<input type='checkbox' value = '14' name = 'January' onblur='getStatus("January")' /><br /><br />

February <input type='checkbox' value = 'main' name = 'February' onblur='getStatus("February")' />
February item 1<input type='checkbox' value = '25' name = 'February' onblur='getStatus("February")' />
February item 2<input type='checkbox' value = '14' name = 'February' onblur='getStatus("February")' />
February item 3<input type='checkbox' value = '6' name = 'February' onblur='getStatus("February")' />
February item 4<input type='checkbox' value = '27' name = 'February' onblur='getStatus("February")' />

Posted: Thu Sep 15, 2005 9:52 am
by pilau
Rag, I get no errors but it's just not working. :P

Posted: Thu Sep 15, 2005 9:58 am
by raghavan20
the event is actually onblur so you have to click on any of the first check boxes (january or february) and click anywhere on the body so trigger the onblur event.

actually you have to change that event later on...but that works... :)

Posted: Thu Sep 15, 2005 9:59 am
by pilau
Nope, it's only half-working.

See, your function can DISABLE the checkboxes, but not ENABLE them back after they've been disable.

Posted: Thu Sep 15, 2005 10:01 am
by raghavan20
pilau, it works well in my system. try it again mate.

refresh the page; check any of the first boxes and click anywhere in the body. that should check all other boxes of the group.

Posted: Thu Sep 15, 2005 10:22 am
by CoderGoblin
You may want to shift click on Reload or clear your cache. (Javascript is often cached rather than reloaded in Firefox).

Posted: Thu Sep 15, 2005 11:52 am
by pilau
Good idea.
Well, I fixed and changed some of the things, added some of my own code, and it's just perfect. Thanks a lot for all who helped me!