SitePoint Sponsor

User Tag List

Results 1 to 4 of 4
  1. #1
    SitePoint Evangelist dscriptor's Avatar
    Join Date
    Oct 2005
    Location
    in front of my computer
    Posts
    571
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Question js code works in IE, Opera but not in Firefox

    Hi all,

    i got a problem here in this Javascipt code to check all the checkbox with an array name of orderitem[]:
    HTML Code:
    function checkAll(myform)
    			{
    			var field = document.getElementsByTagName("orderitem");
    			for (i = 0; i < field.length; i++)
    				field[i].checked = true ;
    			
    			
    			}
    			
    		var formblock;
    		var forminputs;
    		 
    		function prepare() {
    		  formblock= document.getElementById('myform');
    		  forminputs = formblock.getElementsByTagName('input');
    		}
    		 
    		function select_all(name, value) {
    		  for (i = 0; i < forminputs.length; i++) {
    			// regex here to check name attribute
    			var regex = new RegExp(name, "i");
    			if (regex.test(forminputs[i].getAttribute('name'))) {
    			  if (value == '1') {
    				forminputs[i].checked = true;
    				document.myform.total.value = document.myform.totalamount.value;
    			  } else {
    				forminputs[i].checked = false;
    				document.myform.total.value = 0;
    		  }
    			}
    		  }
    		}
    		 
    		if (window.addEventListener) {
    		  window.addEventListener("load", prepare, false);
    		} else if (window.attachEvent) {
    		  window.attachEvent("onload", prepare)
    		} else if (document.getElementById) {
    		  window.onload = prepare;
    		}
    the code above works fine in IE and Opera but not in Firefox.
    I really don't know what's the problem here.

    anyone?

    Thanks.
    happy is the man that finds wisdom....wisdom in {PHP}.


  2. #2
    He's No Good To Me Dead silver trophybronze trophy stymiee's Avatar
    Join Date
    Feb 2003
    Location
    Slave I
    Posts
    23,426
    Mentioned
    2 Post(s)
    Tagged
    1 Thread(s)
    Have you checked the firefox JavaScript error console to see if it is reporting an error?

  3. #3
    SitePoint Evangelist dscriptor's Avatar
    Join Date
    Oct 2005
    Location
    in front of my computer
    Posts
    571
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Error console says: formblock has no properties..

    what do i do? sorry for being noobie here.

    thanks..
    happy is the man that finds wisdom....wisdom in {PHP}.


  4. #4
    SitePoint Evangelist dscriptor's Avatar
    Join Date
    Oct 2005
    Location
    in front of my computer
    Posts
    571
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    thanks. i think i got it. it's only because i have no ID in my form.

    thanks!
    happy is the man that finds wisdom....wisdom in {PHP}.



Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •