select list-drop down menu and php

select list-drop down menu and php

offline
  • Pridružio: 30 Sep 2006
  • Poruke: 137

i got this problem with my script.
here is the code

........ <select name="menu">                 <option value="" selected>Select</option>                    <option value="one">one</option>                    <option value="two">two</option>                    <option value="three">three</option>   </select> <?php Here should be the php code for executing the select

so i when i choose "two" from the menu, i want to go to "two.php".
Any help?


i try this with a submit button but also is not working
........ <select name="menu">                 <option value="" selected>Select</option>                    <option value="one">one</option>                    <option value="two">two</option>                    <option value="three">three</option>   </select> <input type="submit" name="submit" value="submit"> <?php if ($_POST['submit']) {        if ($_POST['menu'] == 'one')        { header "Location:one.php" }        if ($_POST['menu'] == 'two')        { header "Location:two.php" }           if ($_POST['menu'] == 'three')           { header "Location:three.php" } } else{} .......

is this code ok?



Registruj se da bi učestvovao u diskusiji. Registrovanim korisnicima se NE prikazuju reklame unutar poruka.
offline
  • igor86  Male
  • Stručni saradnik
    Web programiranje
  • Pridružio: 24 Maj 2006
  • Poruke: 1633

Use a <form> tags



offline
  • Pridružio: 30 Sep 2006
  • Poruke: 137

lol man, i wrote dots ... that's mean that before the dots there is html script, just like html, body, form etc etc

offline
  • igor86  Male
  • Stručni saradnik
    Web programiranje
  • Pridružio: 24 Maj 2006
  • Poruke: 1633

ok, is problem with header?

offline
  • Pridružio: 30 Sep 2006
  • Poruke: 137

maybe, that i m asking Smile

here is a "visible example"

in the site for php section "http://www.mycity.rs/PHP/" u have on the right a drop down menu..... i think u will find it Smile

offline
  • Pridružio: 11 Maj 2005
  • Poruke: 871
  • Gde živiš: Aleksinac - Niš

You should try using Javascript.
Make a function that will be executed onSubmit.
In that function you check which option is selected.
Something like:
... function setAction() { if(form1.menu.value=="one") {     form1.action="one.php";     form1.submit(); } ... }
I haven't worked in Javascript for quite a long time so I don't know how accurate this code is but I'm sure it can be done this way.

offline
  • PHP developer
  • Pridružio: 22 Mar 2006
  • Poruke: 3609
  • Gde živiš: 127.0.0.1

I use this for redirecting via SELECT box Smile

HTML:

<select name="menu" onchange="RedirectMe(this.value);"> <option value="empty" selected>Select</option> <option value="one">one</option> <option value="two">two</option> <option value="three">three</option> </select>

and JavaScript:

function RedirectMe(page) { var page; if (page != "empty"){ location.href = page+'.php'; } }

offline
  • Pridružio: 30 Sep 2006
  • Poruke: 137

i will try that.

tnx guys

Ko je trenutno na forumu
 

Ukupno su 857 korisnika na forumu :: 32 registrovanih, 2 sakrivenih i 823 gosta   ::   [ Administrator ] [ Supermoderator ] [ Moderator ] :: Detaljnije

Najviše korisnika na forumu ikad bilo je 3028 - dana 22 Nov 2019 07:47

Korisnici koji su trenutno na forumu:
Korisnici trenutno na forumu: amonsrb, Apok, aramis s, Areal84, Djole, doom83, Georgius, goxin, Ilija Cvorovic, ivica976, Kinkou, Konda2, Kos93, lacko, leptirleptir, Lucije Kvint, mercedesamg, Mikulino, Milos ZA, nuke92, royst33, S-lash, sizif, suton, topalovicdj, Trpe Grozni, VaRvArI 85, vasa.93, vathra, xandar, zixmix, zlaya011