Quote:
Originally Posted by Philip M
id is a reserved word.
You should avoid giving names or id's to your variables/functions/arguments/forms words which are HTML/JavaScript methods/properties/attributes such as 'name' or 'id' or 'value' or 'test' or 'text' or 'checked' or 'click' or 'href' or 'closed' or 'go' or 'submit' or 'replace' or 'button' or 'radio' or 'parseInt'.
|
did not know that, thanks for sharing that. That code by the way using the (el, id) came directly from a script i purchased awhile back so i guess i need to change that to. What is strange is that i copied it exactly with all the input elements and all the pieces of the process and it did not work, but it works in the other script.
There are really only three parts, the js, and two inputs. One input for the option to checkall and the other for the id's (wether its a div or an array) thats why i could not believe this was so hard to make work.
But i did get this to work... here is the code im using, if we can improve on it thats great, but it does work so i wanted to share this to help others.
js part.
Code:
function selectAll()
{
var all=document.getElementsByName('selbox[]');
var optall = document.getElementById('select_all');
if(optall.value == 'Select All')
{
for(var i = 0; i < all.length; i++)
{
all[i].checked = true;
}//close for loop
optall.value = 'deselect';
}else{
for(var i = 0; i < all.length; i++)
{
all[i].checked = false;
}//close for loop
optall.value = 'Select All';
}//close else
}//close function selectAll
the select all input checkbox
this is part of what confused me because i could not figure out why we are with passing the value of this in other examples i have found on net when we load the var from the array or div in the js.
we are not passing a value here and it works.
Code:
<input type="checkbox" name="select_all" id="select_all" value="Select All" onClick="selectAll();" />
and lastly the input for the array of row id's
Code:
echo "<input type='checkbox' name='selbox[]' id='selbox' value='$recid' />";
Any improvements u see that need to be done ?
thanks