0

I am trying that when the user chose a specific value of drop down menu, then to execute a specific query.. I have this drop down menu

<select id="cmimetlist" onChange="dropdown()">
  <option value="1"> me pak se 1000</option>
  <option value="2">midis 1000 dhe 2000</option>
  <option value="3">me shume se 2000</option>
 </select>

and this function in javascript

<script>

function dropdown()
{
    var e = document.getElementById("cmimetlist");
    var vlera = e.options[e.selectedIndex].value;
    alert(vlera);
}
</script>

but how to make it that instead of alert do this:

if (vlera == 1)

then execute this query

$run = mysql_query("select * from restorantet, menu where ID_Rest=Rest_ID and Cmimi<1000 ORDER BY Cmimi LIMIT $startrow, 10 ") or Die("ska me te dhena");

if (vlera == 2) execute another query

Thanks in advance

Chen-Tsu Lin
  • 22,876
  • 16
  • 53
  • 63
user3272713
  • 167
  • 2
  • 5
  • 15

2 Answers2

0

I would stick strictly to php for this as it can do the functionality of the javascript as well

I suggest viewing this similar form post as it will probably help

Select tags with php

And querying is simple and you should be able to find how to convert the select tag input into a queryable form of data

Community
  • 1
  • 1
itotallyrock
  • 21
  • 2
  • 7
0

If you want to interactive with backend (such like php) after page render, you must use AJAX technology.

So,

If you use native javascript, search XmlHttpRequest

If you use jQuery, search $.ajax

Chen-Tsu Lin
  • 22,876
  • 16
  • 53
  • 63