note 26132 added to faq.html
| From: | dave dot darden at dev dot null | Date: | Fri, 18 Oct 2002 22:34:35 +0000 |
| Subject: | note 26132 added to faq.html | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-38280@lists.php.net to get a copy of this message | ||
For those who might use a HTML <INPUT> type=button instead of a type=submit, here is an
example javascript function that will send a string of comma delimited codes from the selected
options in a <SELECT MULTIPLE> object. The select multiple object is named
"mycombobox[]" on the form. The entire form is passed to the function as
"myform" in this example.
function runsearch(myform){
myarray = myform.elements['mycombobox[]'];
mystatestring = ',';
for (i=0; i<myarray.length; i++){
if(myarray.options[i].selected == true){
mystatestring += myarray.options[i].value + ',';
}
}
if(mystatestring==','){mystatestring='';}
alert(mystatestring); //for debugging
myurl = 'test21.php?formstatestring=' + mystatestring ;
window.open(myurl,"","menubar=no,toolbar=no");
return;
}
The HTML for the button looks like this, presuming a form with a name of "mainform".
<INPUT type=button value=Submit
onClick="javascript:runsearch(this.document.mainform)">
--
http://www.php.net/manual/en/faq.html.php
http://master.php.net/manage/user-notes.php?action=edit+26132
http://master.php.net/manage/user-notes.php?action=delete+26132
http://master.php.net/manage/user-notes.php?action=reject+26132