php + javascript hard day together ?

From: Date: Sat, 13 Jul 2002 15:37:46 +0000
Subject: php + javascript hard day together ?
Groups: php.general 
Request: Send a blank email to php-general+get-107521@lists.php.net to get a copy of this message
Hi all, I can manage this script to work. Js warn about listid[], he doesnt like [] in a var name ! Php needs them to collect an array from form checkboxes. Here is my source : <!doctype html public "-//W3C//DTD HTML 4.0 //EN"> <html> <head> <title>Title here!</title> <SCRIPT LANGUAGE="JavaScript"> <!-- Begin var checkflag = "false"; function check(field) { if (checkflag == "false") { for (i = 0; i < field.length; i++) { field[i].checked = true; } checkflag = "true"; return "nowhere"; } else { for (i = 0; i < field.length; i++) { field[i].checked = false; } checkflag = "false"; return "everywhere"; } } </script> </head> <body> <? print_r($listid); // what in listid ? ?> <form name=test action=check.php> <input type=button value="partout" onClick="this.value=check(this.form.listid[])"><br> <input type="checkbox" name="listid[]" value="1">1<br> <input type="checkbox" name="listid[]" value="2">2<br> <input type="submit"> </form> <script> var obj=eval('document.test.listid[]'); alert(obj); // no object ! </script> </body> </html> Thanks.

« previous php.general (#107521) next »