I need to get value from Javascript to Php, the scenario is below: I have a drop-down list which is loaded through ajax call, i couldnot find any means to get the value of selected index value of list to a php variable. help plz thanks
it's probably not the conventional way but I just use an image tag and load the source, assuming you only need to set a variable and not give a response. <script type="text/javascript"> function selchange() { document.getElementById("img1").src = "Default.aspx?LID=" + document.getElementById("select1").selectedIndex; } </script> <img style="display:none" id="img1" /> <select id="Select1" name="D1" onchange="selchange()"> <option>Option 1</option> <option>Option 2</option> <option>Option 3</option> </select> Code (markup): I don't use php but you would then have setvar.php which would save the value from the querystring("LID") into a session variable.
I have used the hidden input text field as a way to assign the value. It does assign it. BUT, this all (Dropdown list and hidden text field is in iframe and I do not post it) is inside the iframe. I want to get the hiddentext field value on the parent page, e.g. <?php $value = $_POST['hiddentextfield']; ?>