Re: Multiple select form: is it possible passing javascript variable to PHP?
| From: | Alexey Borzov | Date: | Fri, 04 Aug 2000 07:15:37 +0000 |
| Subject: | Re: Multiple select form: is it possible passing javascript variable to PHP? | ||
| References: | 1 | Groups: | php.db |
| Request: | Send a blank email to php-db+get-1776@lists.php.net to get a copy of this message | ||
Greetings, Eager!
At 04.08.2000, 11:03, you wrote:
EI> I have an html multiple select form and I would like to pass the selected
EI> values into PHP variable and insert the values into MySQL. But when I submit
EI> the values, I got something like:
EI> name.php3?select_name=1&select_name=2&select_name=4
::rolling up eyes::
man, this was in PHP manual!
use <select name="some_array[]">
EI> but I don't know how to pass the value into PHP variable. Can these
EI> javascript variables be passed into PHP or Is there way to work around it? I
EI> know the problem can be solved if I use check boxes or radio buttons but I
EI> must use <select multiple> in my website (the multiple select form is
EI> generated by javascript menu swapper).
if you use javascript to generate this <select>, you can use javascript
to do a workaround like this:
function option_compress(box, field) {
field.value = "";
for (var i=0; i<box.options.length; i++) {
if (i>0)
field.value += ",";
if (box.options[i].selected) {
field.value += box.options[i].value;
box.options[i].selected = false;
}
}
}
<input type="submit" onclick="option_compress(this.form.select_name,
this.form.some_hidden_field); return true;">
--
Yours, Alexey V. Borzov, Webmaster of RDW