Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    Regular Coder
    Join Date
    Sep 2007
    Posts
    809
    Thanks
    5
    Thanked 2 Times in 2 Posts

    Select all checkbox script working on one page but not another?

    Hi all,

    I have a script that checks and unchecks all boxes depending on the current state of the box. I have used it on one page and it works perfectly fine... copied it over to a new page where I wanted to reuse and can't get it to work.

    Code:
    <script type="text/javascript">
    function check_all(form, input_name, self){
    		if(!input_name){
    			return;
    		}
    		
    		var input = form.getElementsByTagName('input');
    		for(var i = 0; i < input.length; i++){
    			if(input[i].name.indexOf(input_name)!=-1){
    				input[i].checked = self.checked;
    			}
    		}
    	}
    </script>
    Code:
    <input type="checkbox" name="notimportant" onclick="check_all(document.form1, 'check', this)" value="test" /><b>All</b>
    Code:
    <input type="checkbox" name="check_list[]" value="<?php echo $row2['email'];?>">
    Code:
    <form name="form1" action="emailspecificcandidates.php" method="post">
    As I say this script works perfectly on another page, and as far as i can see i have copied everything over correctly.

    Can anyone spot anything wrong?

    Many thanks,

    Greens85

    EDIT: I think this may be broken because of the way I presenting it with php on my page... i copied a seperate entity of the script onto the page and it worked first time.
    Last edited by greens85; 11-17-2010 at 02:55 PM. Reason: UPDATE

  • #2
    Regular Coder
    Join Date
    Sep 2007
    Posts
    809
    Thanks
    5
    Thanked 2 Times in 2 Posts
    This is now solved, it was due to where i was placing the opening form tag!


  •  

    Posting Permissions

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