I am trying to collect value of select box first by using javascript and this stored value i need in php variable for select value from select box second.
5
-
you need to use ajax in that caseYassine CHABLI– Yassine CHABLI2019-04-02 10:44:21 +00:00Commented Apr 2, 2019 at 10:44
-
It's not entirely clear what you're trying to accomplish. But in order to send a value to your PHP code that value needs to be sent to the server. Either in a form post, or AJAX, or perhaps a query string value on a redirect. It sounds like you want the user to stay on the same page, so that would mean using AJAX.David– David2019-04-02 10:46:15 +00:00Commented Apr 2, 2019 at 10:46
-
I know it is difficult to write a good question. Just remember to keep the title as short as possible and, if you have it, illustrate your question with some real programming code.KIKO Software– KIKO Software2019-04-02 10:48:36 +00:00Commented Apr 2, 2019 at 10:48
-
M totally agreed with you #KIKO Softwaer. my problem is that, I have two select box and both are dynamic, select box1 is for some selection value and select box2's value depend on select box1's value. now i retrive the value on select box1's value by using onchange() function in script but i want this value in PHP variable($abc).Swatantra Jain– Swatantra Jain2019-04-02 11:11:14 +00:00Commented Apr 2, 2019 at 11:11
-
Thank You to all for your precious help, I used an Ajax code to resolve this problem.Swatantra Jain– Swatantra Jain2019-04-04 06:00:37 +00:00Commented Apr 4, 2019 at 6:00
Add a comment
|
1 Answer
I was stuck with the same problem. Resolved it with the help of jquery and ajax.
first, collect the data with the help of javascript, then send it to the desired page with the help of ajax, and then redeem it by $this->input->post() or get(), whichever way you like.
5 Comments
Swatantra Jain
all good but i don't wanna send data to other page. i want to use this value at the same page
Danyal Sandeelo
@SwatantraJain why do you want to do that? reason?
Swatantra Jain
@Danyal Sandeelo- the value of select box 1 will help me to filter data of select box 2, so i tried it by onchange function(). value of select box 1 is successfully returned by onchange function but this value is in form of function variable[var x=document.getElementById("mediatype"); var strUser = x.options[x.selectedIndex].text; ] but i need this value in PHP variable like("$abc" variable)
Danyal Sandeelo
you will have to make an ajax call after selecting value 1 from combo 1, get all the json of values for combox 2, set all the values to combox 2 … these are basically dependent dropdowns, the second one is dependent on 1st one.
Swatantra Jain
Thank You to all for your precious help, I used an Ajax code to resolve this problem.