codetoad.com
  ASP Shopping CartForum & BBS
  - all for $20 from CodeToad Plus!
  
  Home || ASP | ASP.Net | C++/C# | DHTML | HTML | Java | Javascript | Perl | VB | XML || CodeToad Plus! || Forums || RAM 
Search Site:
Search Forums:
  problems with onload  Matt1776 at 23:13 on Thursday, June 08, 2006
 

im executing the following code as an external JS file for some checkboxes. The idea is to allow the user to check 'all' without having to check each one:


// onclick="return setAllCheckboxes(this, checkboxGroupName)"

function setAllCheckboxes(ctrl, group) {
var x, len = group.length;
for(x=0; x<len; ++x) {
group[x].checked = ctrl.checked;
}
return true;
}


However, i want one of these sets of checkboxes to be selected when the user enters the page, i tried the following when calling the function but i had no success:


print("<tr><td><input type=\"checkbox\" id=\"allBox\" onload=\"return setAllCheckboxes(this, laneBox)\"
onclick=\"setAllCheckboxes(this, laneBox);\"></td><td colspan=\"$allspan\">ALL</td></tr>\n");


If anyone has any insight on how to accomplish this it would be very appreciated. I dont want to use a form name or reference any JS in the body tag, im developing a self contained function that someone else will use.

thanks in advance! :D

  Re: problems with onload  hemangkapadia at 12:33 on Wednesday, July 26, 2006
 

Hi,
First of all its suprising why u pass 2 parameters which are the same , i think instead of passing "this" which is same as the pbject which u are apassing as 2nd param , u pass true or false as the first paramtere and change the function as

function setAllCheckboxes(ctrl, group) {
var x, len = group.length;
for(x=0; x<len; ++x) {
group[x].checked = ctrl; // modified by Hemang
}
return true;
}

and then u can call this function onload event of body and this will work fine








CodeToad Experts

Can't find the answer?
Our Site experts are answering questions for free in the CodeToad forums
//








Recent Forum Threads
•  IE Only comeback
•  Re: java app auto web update..
•  ` Error Code 64: Host not available ` - Error when accessing ASP Appln
•  Re: dynamic crystal report generation
•  Launch an app remotely through a website
•  Run an app in my pc from another pc
•  a:hover elements
•  Rearranging elements in a table
•  window.open giving http404 error


Recent Articles
ASP GetTempName
Decode and Encode UTF-8
ASP GetFile
ASP FolderExists
ASP FileExists
ASP OpenTextFile
ASP FilesystemObject
ASP CreateFolder
ASP CreateTextFile
Javascript Get Selected Text


© Copyright codetoad.com 2001-2007