Poslao: 03 Mar 2007 13:17
|
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.
|
|
|
Poslao: 03 Mar 2007 18:06
|
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
|
|
|
|
|
Poslao: 03 Mar 2007 22:51
|
offline
- Pridružio: 30 Sep 2006
- Poruke: 137
|
maybe, that i m asking
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
|
|
|
|
Poslao: 04 Mar 2007 11:28
|
offline
- stankovic
- Prijatelj foruma
- 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.
|
|
|
|
Poslao: 04 Mar 2007 14:36
|
offline
- Rastafarii
- Moderator foruma
- Pridružio: 22 Mar 2006
- Poruke: 3760
- Gde živiš: 127.0.0.1
|
I use this for redirecting via SELECT box
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';
}
}
|
|
|
|
|