Subject: give checkbox value
Posted By: hastikeyvan Post Date: 12/26/2005 7:12:25 AM
hello again
can we give checkbox value for check or uncheck in this way?would you please tell me what is wrong with it?
i placed a button(check all button)and i want to check all my checkboxes with clicking the button

<input type="button" Name="CheckAll">
<script for="CheckAll" language="vbscript" event="onclick">
        
document.formname.checkboxname.value="1"

                  
                
                </script>


Reply By: Imar Reply Date: 12/27/2005 4:32:12 PM
Hi there,

You need to loop through the Form collection and diagnose each control. When it's a check box, set its checked property:

function CheckAll()
{
  for (var i = 0; i < document.MyForm.elements.length; i++)
  {
    if(document.MyForm.elements[i].type == 'checkbox')
    {
      document.MyForm.elements[i].checked = true
    }
  }
}

It's JavaScript, but the same principle applies to VBScript.

HtH,

Imar
---------------------------------------
Imar Spaanjaars
Everyone is unique, except for me.
Reply By: hastikeyvan Reply Date: 12/28/2005 12:20:25 AM
thank you Imar.it is working now and i learned a very usefull thing


Go to topic 38012

Return to index page 409
Return to index page 408
Return to index page 407
Return to index page 406
Return to index page 405
Return to index page 404
Return to index page 403
Return to index page 402
Return to index page 401
Return to index page 400