
October 21st, 2003, 12:21 PM
|
|
|
|
Join Date: Apr 2007
Location: Ottawa, Ontario, Canada
Posts: 123
Time spent in forums: < 1 sec
Reputation Power: 2
|
|
|
Validation - multiple checkboxes, one name
I have a form on a page with multiple checkboxes under one name. The value for them is an ID number.
the checkbox looks like this:
php Code:
Original
- php Code |
|
|
|
echo "<input type='checkbox' name='l_id[]' value='$row[0]'>";
There are also numerous tables with these checkboxes set up for each database in the system where the users are found with ID's.
At the bottom of the tables, there is a button to be clicked, that removes the users who are checked off from the system (logs them out).
The form and the button:
php Code:
Original
- php Code |
|
|
|
//top of form echo "<form name='logout' method='GET' action='$PHP_SELF' onSubmit='return validate_logout(this)'>"; //bottom of form echo "<input name='submit' type='submit' value='logout'></form>";
Ok... so this is the validation located in a seperate .inc file in Java Script
php Code:
Original
- php Code |
|
|
|
<script> function validate_logout(form) { var submitform = true; var errors = "You have errors in the following fields: nn"; var l_id = eval ("document.forms[0].elements['l_id']"); if(l_id == "") { submitform = false; errors += "No Users Checkedn"; } if (submitform == false) { alert(errors); return false; } } </script>
Now I have tried different things. For instance I know chjecked and false have to be in there somewhere, but it wouldn't work.
Any ideas ?
Thanks.
|