I'm having a problem in passing variable from Javascript to PHP,
passing variables from PHP to Javascript is Easy
but is there a way to pass Variables from Javascript to PHP?
Here's the Situation
Think of this as the variables of the first select input
--2010
--2011
--2012
and
the Values of the second select group varies depending on the selected option
of the first select group
The values are:
2010
--AAA
--AAB
--AAC
2011
--ABA
--ABB
--ABC
2012
--ACA
--ACB
--ACC
say that the values are displayed by a conditional PHP function that
retrieves data from a Database
Here's What I Want to do:
When I Select One from the first select Group,
It will change the options of the second select group
of course, this happens via triggers when the first select group changes
I need to Retrieve the value of the first select group to filter the data
that will be displayed as the options of the second Group which comes from
a database and a PHP function is made to process it, thats why i need the value
of the first select group and use it as a parameter for the second select group.
The Problem:
i need to get the value of the first select group in PHP Varible
to make a PHP Function work.
Please Help!!!
Tell me more
×
Stack Overflow is a question and answer site for
professional and enthusiast programmers. It's 100% free, no registration required.
|
|||||||
|
You can simply add it in as a url parameter in the ajax request that you send. Consider your first field is like so:
Your javascript will be like so:
And then you will send the ajax request to In the php, you will get this value as
|
|||||||||||
|
Like said above, your fields are
Use jQuery to perform an AJAX call to your script. Something like that
In your php script, variable passed from jQuery will be available like this
|
|||||||||
|