Re: Array issue

From: Date: Wed, 25 Sep 2002 06:16:00 +0000
Subject: Re: Array issue
References: 1  Groups: php.windows 
Request: Send a blank email to php-windows+get-15994@lists.php.net to get a copy of this message
Are you sure about this checked() function? Is it a custom function of your own? Methinks the standard way to check/ uncheck a checkbox would be: document.myform.mycheckboxfield.checked = true ; (or false) HTH Ignatius -------------------------------------------------------------------------------- ----- Original Message ----- From: Kit Kerbel To: php-windows@lists.php.net Sent: Wednesday, September 25, 2002 4:26 AM Subject: [PHP-WIN] Array issue I have this in my code: <input type="checkbox" name="tack[]" value="<?echo odbc_result($rs3,"dTackID");?>"> I'm passing this to a javascript function like this to check all checkboxes: onClick="this.src = check(document.forms[0].elements['horse[]'], document.forms[0].elements['trailer[]'], document.forms[0].elements['tack[]'])" My problem is this...if there are two horse/trailer/tack checkboxes on the page...it will check/uncheck them fine. However, if there is only one element in the array when passed in, it will do nothing to the checkbox. No errors show up or anything, just nothing happens to the lone checkbox. Here is the javascript code for those interested: <SCRIPT LANGUAGE = "JavaScript"> var checkflag = "false"; function check(field, field1, field2) { if (checkflag == "false") { if(field) { for (i=0; i<field.length; i++) {field[i].checked = true;} } if(field1) { for (i=0; i<field1.length; i++) {field1[i].checked = true;} } if(field2) { for (i=0; i<field2.length; i++) {field2[0].checked = true;} } checkflag = "true"; return "images/button_unselectall.gif"; } else { if(field) { for (i=0; i<field.length; i++) {field[i].checked = false;} } if(field1) { for (i=0; i<field1.length; i++) {field1[i].checked = false;} } if(field2) { for (i=0; i<field2.length; i++) {field2[i].checked = false;} } checkflag = "false"; return "images/button_selectall.gif"; } } </script> If you can help that would be great, thanx in advance, Kit _________________________________________________________________ MSN Photos is the easiest way to share and print your photos: http://photos.msn.com/support/worldwide.aspx -- PHP Windows Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php

« previous php.windows (#15994) next »