RE: [PHP] php + javascript hard day together ?
-Original Message- From: David D [mailto:[EMAIL PROTECTED]] Sent: 13 July 2002 16:38 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. form name=test action=check.php input type=button value=partout onClick=this.value=check(this.form.listid[])br use this.form['listid[]'] It seems to be a very little known fact that, by definition, the JavaScript construct x.y is identical to x['y'] so an extended accessor such as w.x.y.z could also be written equally validly in any of the following ways: w.x.y['z'] w.x['y'].z w['x'].y.z w['x'].y['z'] w['x']['y'].z and several other similar combinations! (And, yes, that means that this['form']['listid[]'] should be valid, too!) Cheers! Mike - Mike Ford, Electronic Information Services Adviser, Learning Support Services, Learning Information Services, JG125, James Graham Building, Leeds Metropolitan University, Beckett Park, LEEDS, LS6 3QS, United Kingdom Email: [EMAIL PROTECTED] Tel: +44 113 283 2600 extn 4730 Fax: +44 113 283 3211 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] php + javascript hard day together ?
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 titleTitle 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=11br input type=checkbox name=listid[] value=22br input type=submit /form script var obj=eval('document.test.listid[]'); alert(obj); // no object ! /script /body /html Thanks. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] php + javascript hard day together ?
On Saturday 13 July 2002 23:37, David D wrote: Hi all, I can manage this script to work. Js warn about listid[], he doesnt like [] in a var name ! There's nothing you can do about that. Php needs them to collect an array from form checkboxes. You'll just have to rename your checkboxes to something like listid_1, listid_2 etc. Then loop: # Untested code, use with caution for ($i = 1; $i $number_of_checkboxes; $i++) { if (isset($_GET[listid_$i])) { echo listid_$i is checkedbr; } } -- Jason Wong - Gremlins Associates - www.gremlins.com.hk Open Source Software Systems Integrators * Web Design Hosting * Internet Intranet Applications Development * /* Bunker's Admonition: You cannot buy beer; you can only rent it. */ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] php + javascript hard day together ?
I hack js no need to change in php : SCRIPT LANGUAGE=JavaScript !-- Begin var checkflag = false; // on va se ballader parmis les elements de formualire et toucher // au case a cocher function check(formulaire) { if (checkflag == false) { for (i = 0; i formulaire.length; i++) { if (formulaire.elements[i].type.toLowerCase() == 'checkbox') { formulaire.elements[i].checked = true; } } checkflag = true; return Nulpart; } else { for (i = 0; i formulaire.length; i++) { if (formulaire.elements[i].type.toLowerCase() == 'checkbox') { formulaire.elements[i].checked = false; } } checkflag = false; return Partout; } } /script I pass teh form to the function and scan its elements -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php