Re: Pb to submit a form

From: Date: Thu, 19 Oct 2000 18:21:53 +0000
Subject: Re: Pb to submit a form
References: 1  Groups: php.db php.windows 
Request: Send a blank email to php-db+get-3804@lists.php.net to get a copy of this message
on 10/19/00 8:55 AM, CESBRON S. at scesbron@escna.fr wrote: > Hi everybody, > > I've got a huge problem and I don't know how I can solve. I hope that you > guys can help me. > > I'd like to test a form to know if all fields are well fullfill before > sending this form to my php script. > The pb comes with a multiple select statement. > > To be able to test it in Javascript, I should have : > <select multiple name="languages"> and I can do > document.myform.languages.selectedIndex to know if something was selected.. > But if I do so, I can only read the last selected option in my php script.. > > The pb is that to be able to read all selections, that user made, from my > php script I should have : > <select multiple name="languages[]"> and so I can't test it in javascript > ( document.myform.languages.selectedIndex doesn't work > document.myform.languages[].selectedIndex doesn't work neither > document.myform.(languages[]).selectedIndex doesn't work neither ) > > > Is anybody aware of this and know how I can solve it ? > > Stéphane > Try this, DAve. <html> <head> <title>test.html</title> <script type="text/javascript" language="javascript"> function showMe() { var thisForm = document.myForm.mySelect; var tVar = ''; // get the selection list length and run through it for (var zCnt = 0; zCnt < thisForm.options.length; zCnt++) { // check to see if each item is selected if (thisForm.options[zCnt].selected) { // first item in the list needs no delimiter if (tVar == '') { tVar = thisForm.options[zCnt].value; } else { tVar += ':' + thisForm.options[zCnt].value; } } } // what did we find? window.status = 'current tVar value today is => ' + tVar; } </script> </head> <body> <form name='myForm'> <select name="mySelect" size="5" multiple> <option label="0" value="0">0</option> <option label="1" value="1">1</option> <option label="2" value="2">2</option> <option label="3" value="3">3</option> <option label="4" value="4">4</option> </select> <input type='button' value='show me' onClick='javascript:showMe();') </form> </body> </html>

« previous php.db (#3804) next »