Discussion:
jquery fill select option value
iccsi
2013-09-22 01:06:59 UTC
Permalink
<select id="mark" name="mark">
<option value="">--</option>
<option value="bmw">BMW</option>
<option value="audi">Audi</option>
</select>

I use above code to have my select drop down on the form and would like to
use jQuery to fill option value on change event.
I would like know is it possible to do, if yes, any hint or example code at
server site is appreciated,

Your help and information is great appreciated,

Regards,

Iccsi,
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
Ashley Sheridan
2013-09-22 07:52:52 UTC
Permalink
Post by iccsi
<select id="mark" name="mark">
<option value="">--</option>
<option value="bmw">BMW</option>
<option value="audi">Audi</option>
</select>
I use above code to have my select drop down on the form and would like to
use jQuery to fill option value on change event.
I would like know is it possible to do, if yes, any hint or example code at
server site is appreciated,
Your help and information is great appreciated,
Regards,
Iccsi,
Yes it is possible but a) not at server side because JavaScript is run on the browser, and b) this is a PHP list not a JavaScript list.

Saying that, why aren't you populating it on the server side with PHP?

Thanks,
Ash
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
Jim Giner
2013-09-22 13:12:42 UTC
Permalink
Post by Ashley Sheridan
Post by iccsi
<select id="mark" name="mark">
<option value="">--</option>
<option value="bmw">BMW</option>
<option value="audi">Audi</option>
</select>
I use above code to have my select drop down on the form and would like to
use jQuery to fill option value on change event.
I would like know is it possible to do, if yes, any hint or example code at
server site is appreciated,
Your help and information is great appreciated,
Regards,
Iccsi,
Yes it is possible but a) not at server side because JavaScript is run on the browser, and b) this is a PHP list not a JavaScript list.
Saying that, why aren't you populating it on the server side with PHP?
Thanks,
Ash
Not sure what you are asking. With PHP it is possible to have a specifi
item from the options selected in the drop down when the page is loaded.
With JS it is possible to capture the newly selected option value and
place it in another field, if that is what you want. Obviously when the
user clicks on an option, that value IS placed in the select tag for
processing at the server side by PHP on submit.

So what is it you want to accomplish?
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
Tedd Sperling
2013-09-22 16:04:24 UTC
Permalink
Post by iccsi
<select id="mark" name="mark">
<option value="">--</option>
<option value="bmw">BMW</option>
<option value="audi">Audi</option>
</select>
I use above code to have my select drop down on the form and would like to use jQuery to fill option value on change event.
I would like know is it possible to do, if yes, any hint or example code at server site is appreciated,
Your help and information is great appreciated,
While jQuery is great, you don't need jQuery for this -- a simple AJAX routine will do what you want. Here's an example:

http://php1.net/a/zipcode-states/

The ajax routine is there -- you can copy it.

The HTML is there -- you can copy that too.

The php script is a simple script that is triggered by an ajax script (triggered by the user via onchange() ) that then pulls whatever data is needed to populate the remaining option controls via a GET.

HTH's

tedd

_______________
tedd sperling
***@gmail.com
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
Jim Giner
2013-09-22 16:47:41 UTC
Permalink
Post by Tedd Sperling
Post by iccsi
<select id="mark" name="mark">
<option value="">--</option>
<option value="bmw">BMW</option>
<option value="audi">Audi</option>
</select>
I use above code to have my select drop down on the form and would like to use jQuery to fill option value on change event.
I would like know is it possible to do, if yes, any hint or example code at server site is appreciated,
Your help and information is great appreciated,
http://php1.net/a/zipcode-states/
The ajax routine is there -- you can copy it.
The HTML is there -- you can copy that too.
The php script is a simple script that is triggered by an ajax script (triggered by the user via onchange() ) that then pulls whatever data is needed to populate the remaining option controls via a GET.
HTH's
tedd
_______________
tedd sperling
OH!!! So you want to populate another(!) select box after the user makes
his first selection. You didn't say that.

Yes - ajax call would be just what you want to do.
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
Tedd Sperling
2013-09-22 16:57:42 UTC
Permalink
Post by Tedd Sperling
Post by iccsi
<select id="mark" name="mark">
<option value="">--</option>
<option value="bmw">BMW</option>
<option value="audi">Audi</option>
</select>
I use above code to have my select drop down on the form and would like to use jQuery to fill option value on change event.
I would like know is it possible to do, if yes, any hint or example code at server site is appreciated,
Your help and information is great appreciated,
http://php1.net/a/zipcode-states/
The ajax routine is there -- you can copy it.
The HTML is there -- you can copy that too.
The php script is a simple script that is triggered by an ajax script (triggered by the user via onchange() ) that then pulls whatever data is needed to populate the remaining option controls via a GET.
HTH's
tedd
OH!!! So you want to populate another(!) select box after the user makes his first selection. You didn't say that.
I use above code to have my select drop down on the form and would like to use jQuery to fill option value on change event.
I took that to mean fill "another" option control. Why would one want to change the values of the current one?

tedd

_______________
tedd sperling
***@gmail.com
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
Loading...