0

How do I get the current selected value on my dropdown? And pass it on my php variable?

<select name="f_country_id">
<option value="0">-Select country-</option>
<option value="1">Brazil</option>
<option value="2">Canada</option>
<option value="3" selected>Denmark</option>
<option value="4">Philippines</option>
<option value="5">USA</option>
</select>

Then onChange i need also to get the new value selected. And output it on a page inside a php variable.

Do I need to reload the page and use the GET["f_country_id"] as url variable to achieve it. Because I'll be using the id value for my search.

Please help and advise.

RJJMMJ
  • 1
  • 1
  • Tell us what you have tried yet ? – Rahul Feb 16 '17 at 06:52
  • I suggest query params to manipulate current page's data , use GET params – Ashok Mandal Feb 16 '17 at 06:54
  • `$("[name="f_country_id"] option:selected").val()` use ajax or form submit to pass value to php – guradio Feb 16 '17 at 06:54
  • _"output it on a page inside a php variable"_ On what page? Where? New window? Replace this page? Iframe? Frames? Please clarify your question and what it is you're trying to accomplish. – M. Eriksson Feb 16 '17 at 06:55
  • Im just using one page for my search page. I just need to get the current selected value and pass it to a php variable so i can use it on a query. – RJJMMJ Feb 16 '17 at 07:10
  • Dont know how to pass the JS var into PHP var – RJJMMJ Feb 16 '17 at 07:19

0 Answers0