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: 3760
  • 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 1282 korisnika na forumu :: 88 registrovanih, 9 sakrivenih i 1185 gosta   ::   [ Administrator ] [ Supermoderator ] [ Moderator ] :: Detaljnije

Najviše korisnika na forumu ikad bilo je 3466 - dana 01 Jun 2021 17:07

Korisnici koji su trenutno na forumu:
Korisnici trenutno na forumu: Alexa77, Asparagus, bojan581, bojan_t, bokki, boromir, bukefal, burevestnik, Carl Gustaf, casual03, CrazyNorth, cuculo, debeli, Dejan_vw, Demi87, Django777, Dragon Order, dulleo, Dzigy, ElvisP, Feller, gacesam, galerija, Georgius, gorankuba, goranvas, GveX, hooraay, HrcAk47, ikan, ILGromovnik, istina, ivan_8282, ivran064, jackreacher011011, Jakonjveliki, janbo, Još malo pa deda, Kriglord, ljuba.b, Lotus, Lošmi, luka1978, macak44, mango, Marex, mayorlany, metallac777, milos97, mitja2512, Mrav Obrad, Murko, Natuzzi, nenaddz, nesa1962, Nikolajevic, niksa517, nobutado, pajovukosavljevic, Parker, Petarvu, Pilence, Plavi Jadran, PrincipL, ruger357, SamostalniReferent, Sančo, Sr.Stat., starlights, superwhy, suton, synergia, The Boss, Toper, umpah-pah, Van, vasa.93, vathra, vensla, Vladonius, x011, yiyi, YugoSlav, Zanim98, ZetaMan, zlaya011, zmajognjeniivan, Zrcalo