Page 1 of 1
drop down list
Posted: Fri Oct 17, 2008 4:43 am
by littlecoder
Hello friends,
Is there any way to get the value from a drop down list at the instant it is clicked and not
when the 'Submit' button is pressed ?
Thanks in advance...
Re: drop down list
Posted: Fri Oct 17, 2008 4:53 am
by requinix
Heh. Just realized I said "button". I meant "dropdown".
JavaScript. One way or another.
Add an onclick event to the button to submit the form. All it does is save the user the terrible task of moving the mouse an inch and slightly depressing one of the buttons.
Re: drop down list
Posted: Fri Oct 17, 2008 5:00 am
by littlecoder
Hi ,
Yes, but that would only get the value in the javascript vode..
Is it possible to get that value into a php variable?
Re: drop down list
Posted: Fri Oct 17, 2008 5:01 am
by requinix
littlecoder wrote:Hi ,
Yes, but that would only get the value in the javascript vode..
Is it possible to get that value into a php variable?
I wrote:JavaScript. One way or another.
Either the form gets submitted or you use something like AJAX.
Re: drop down list
Posted: Fri Oct 17, 2008 6:08 am
by papa
littlecoder wrote:Hi ,
Yes, but that would only get the value in the javascript vode..
Is it possible to get that value into a php variable?
Not true. You pass the var as as post or get.
$_GET[], $_POST[]
I use this:
<select onchange='this.$form_name.submit()'>
Re: drop down list
Posted: Fri Oct 17, 2008 6:30 am
by VladSun
papa wrote:I use this:
<select onchange='this.$form_name.submit()'>
According to HTML DOM standards, every form element has a form property - the owning form element. So, I would rewrite your code as:
Code: Select all
<select onchange='this.form.submit()'>
Re: drop down list
Posted: Fri Oct 17, 2008 6:33 am
by papa
Oops,
That's actually how I use it. Copied it wrong from my function.
...
$onSubmit = "onchange='this.form.submit()' ";
return "<select ".$onSubmit.$formSelect;
...
Re: drop down list
Posted: Fri Oct 17, 2008 7:03 am
by littlecoder
Hi friends ,
Thank you...The 'this.form.submit()' worked...
saved me a lot of time...Thank you