tags:

views:

395

answers:

5

PLEASE NO JS!!!

<select>
  <option value="volvo">Volvo</option>
  <option value="saab">Saab</option>
  <option value="mercedes">Mercedes</option>
</select>

I simply want that whenever someone selects "saab", the page would reload. It's kinda like having the whole <select> inside a form (which is the ultimate solution), but I need no "submit" button. Is this feasible strictly with PHP?

+3  A: 

No, this always requires javascript to hook the event that indicates that another option has been selected.

Sander Rijken
+6  A: 

You need to keep in your mind that PHP works in the Server side. What you want is something in the client side, which means you didn't send anything to the server, so that PHP can process. So you need some client side solution, like Javascript.

Eduardo
But isn't it possible for the <select> to kinda work like a submit button?
sombe
No, no way. Can't be done.
Pekka
some sites do that. But they use JavaScript.
Carson Myers
Yes, the select can work litle a submit button, like any other html tag, but it still requires Javascript to tell the tag to behave like that.
Eduardo
A: 

PHP is only on the server side. But what you want is something that happens only on the client side (browser). So you definitely need something like Javascript.

Raffael Luthiger
+1  A: 

This is what it would look like in JS:

<select onchange='if(this.value == "saab") alert("We will miss you!");'>
Pekka
The first line of his question says: "please no JS".
Eduardo
So what? There are four answers stating that it can't be done without.
Pekka
A: 

You can only do that if you have a list with a bunch of submit buttons and make it look like a dropdown with a shot of CSS. The only caveat is that every item would then submit the form to the server.

BalusC