The following works in IE 6 I haven't tested in any other environment
though.

<a href="" fncSelectAll();">Select All</a> | <a href=""> fncClearCheck();">Deselect All</a>

<script language="_javascript_">
function fncSelectAll()
{
  var CollInput = document.all.tags('INPUT')
  for ( i = 0 ; i< CollInput.length; i++)
   CollInput[i].checked = true;

  return false;
}

function fncClearCheck()
{
  var CollInput = document.all.tags('INPUT')
  for ( i = 0 ; i< CollInput.length; i++)
   CollInput[i].checked = false;

  return false;
}
</script>

  -----Original Message-----
  From: Tim Laureska [mailto:[EMAIL PROTECTED]
  Sent: Thursday, October 23, 2003 9:36 AM
  To: CF-Talk
  Subject: JS help - select all checkboxes

  This is probably old hat for most, but it's a first for me....

  I have a page of records laid out in a table that results from a query
  ... I want the option to delete all records or individual ones.
  Therefore, I have checkboxes next to each record.. deleting individual
  records was not a problem... but when I tried to use/modify a piece of
  js (script found on the net) to do a select all scenario, it throws a JS
  error ... I think because the records are dynamically generated.... I've
  seen some obscure references on how to do this "select all" scenario
  with multiple, dynamically generated records, but nothing I can put
  together to make it work.

  Can someone point me in the right direction here... the code I'm using
  off the net, which works fine in a static situation, is below , but of
  course there's only one <input type> line in my template

  <form name=f1>
  <input type="checkbox" name="c1" value="1">c1-1<BR>
  <input type="checkbox" name="c1" value="2">c1-2<BR>
  <input type="checkbox" name="c1" value="3">c1-3<BR>
  <input type="checkbox" name="c1" value="4">c1-4<BR>
  <input type="checkbox" name="c1" value="5">c1-5<BR>
  <input type="checkbox" name="c2" value="1">c2-1<BR>
  <input type="checkbox" name="c2" value="2">c2-2<BR>
  <input type="checkbox" name="c2" value="3">c2-3<BR>
  <input type="checkbox" name="c2" value="4">c2-4<BR>
  <input type="checkbox" name="c2" value="5">c2-5<BR>

  <input type="checkbox" name="c3" value="false"
   Not Checked<BR>
  <input type="checkbox" name="c4" value="true"
   Checked<BR>
  </form>
  <script>
  function doIt(v)
  {
  for(var i=0;i<document.f1.c1.length;i++)
     document.f1.c1[i].checked=eval(v);
  for(var i=0;i<document.f1.c2.length;i++)
     document.f1.c2[i].checked=eval(v);
  document.f1.c3.checked=false;
  document.f1.c4.checked=false;
  }
  </script>

  Tim


[Todays Threads] [This Message] [Subscription] [Fast Unsubscribe] [User Settings]

Reply via email to