Hi I’m not sure whether this is a php, javascript or ajax question. Because I’m using wordpress press I think ultimately my solution needs to be php. I have a select form with an array of options, the select id is “company_size”. When an option is selected I can get the selected value with the below jquery. How would I go about turning this into a php variable? Or can I just can get the value with php? any help would be great. Cheers
var $j = jQuery.noConflict();
var size= $j("#company_size :selected").text();
It’s kind of hack-ish, but you could use AJaX to send that value to a php page that inserts the value into the session scope, making it available globally.
The answer depends on what you are doing exactly. If the user selects an option and the results are shown on a new page, the data would be submitted in a form. The form can be submitted by query using the ‘change’ event.
A global variable would be hackish and isn’t needed. There are a couple of methods that I outlined above for sending the variable directly to a php processor.