0

As part of a PHP page, I have a form. In the form a DropDownBox has been used. I need to retrieve the value selected by the user, preferably in a session variable, BEFORE the form is submitted. I need this because, based on the value chosen by the user, I'll need to give them additional textboxes and radio buttons to input more data which, along with other details, then has to be stored in the database. The problem is, in order to use POST/GET/REQUEST, I'll need to send the data to another link. I do NOT want that.

I also tried using javascript, onChange event. How do I convert the javascript variable into a PHP variable? Is there another way to go about this?

user657592
  • 1,031
  • 4
  • 16
  • 24

2 Answers2

1

You can use jquery. Here is a similar thread that may address your question.

Get selected text from a drop-down list (select box) using jQuery

jquery get selected value from dropdownlist? Not text

http://forum.jquery.com/topic/jquery-get-selected-value-in-dropdown

After getting the value, send an ajax request to php which in turn return a value. Using the return value, you can do more processing. You can take a look at jquery ajax at http://api.jquery.com/jQuery.ajax/

Community
  • 1
  • 1
Slay
  • 1,285
  • 4
  • 20
  • 44
0

The way I've gone between Javascript and Server Scripts is using a hidden input field. This way you can send that value you when you submit the form and you can manipulate the value client-side as well. But using AJAX is a good way to go as well.

ExceptionLimeCat
  • 6,191
  • 6
  • 44
  • 77