You are here: Re: [PHP] Re: select-option link list « PHP « IT news, forums, messages
Re: [PHP] Re: select-option link list

Posted by Richard Morley on 01/19/05 23:27

This should work

<html>
<body>
<form>
<select size=3D"1" name=3D"site" onChange=3D"if(this.value !=3D =

'')window.location=3Dthis.value">
<option value=3D"">Please select a site to visit</option>
<option value=3D"http://www.google.com">Google</option>
<option value=3D"http://www.yahoo.com">Yahoo</option>
<option value=3D"http://www.microsoft.com">MS</option>
</select>
</form>
</body>
</html>


On Wed, 19 Jan 2005 22:23:52 +0100, Jochem Maas <jochem@iamjochem.com> =

wrote:

> Ricky Morley wrote:
>> Like this. Here's the html code. I'm sure you can convert to the =

>> appropriate PHP
>>
>
> this is totally not PHP but...
>
>> <html>
>> <body>
>> <form>
>> <select size=3D"1" name=3D"site" onChange=3D"window.location=3Dthis.v=
alue">
>
> shouldn't that be something like:
>
> <select size=3D"1"
> name=3D"site" =

> onChange=3D"if
> (this.options[this.selectedIndex].value) {
> window.location=3Dthis.options[this.selectedIndex].value;
> }">
>
> which is evil and crude, but does 2 things: uses the selectedIndex to =
=

> get the value of the selection options and only sets the window locati=
on =

> is the value if not empty.
>
>
>> <option value=3D"http://www.google.com">Google</option>
>> <option value=3D"http://www.yahoo.com">Yahoo</option>
>> <option value=3D"http://www.microsoft.com">MS</option>
>> </select>
>> </form>
>> </body>
>> </html>
>> On Wed, 19 Jan 2005 20:10:25 +0200, William Stokes =

>> <kalles@operamail.com> wrote:
>>
>>> Hello,
>>>
>>> Hope someone can give some directions...
>>>
>>> I'm trying to create a list box of links to other pages. I just can'=
t =

>>> figure
>>> out how to move to the other page whe user selects one of the option=
s =

>>> in the
>>> list box.
>>>
>>> here's the code...
>>>
>>> $sql=3D"SELECT team_name FROM teams";
>>> $result=3Dmysql_query($sql);
>>> $num =3D mysql_num_rows($result);
>>> $cur =3D 1;
>>> print "<form name=3D\"form1\" method=3D\"post\" =

>>> action=3D\"select_team.php\">";
>>> print "<select name=3D\"select_team\" size=3D\"1\" >";
>>> while ($num >=3D $cur) {
>>> $row =3D mysql_fetch_array($result);
>>> $team_name =3D $row["team_name "];
>>> print "<option>$team_name </option>";
>>> $cur++;
>>> }
>>> print "</select>";
>>> print "<input type=3D\"submit\" value=3D\"Go!\">";
>>> print "</form>";
>>>
>>> This propably can be don without the "Go" button. But i Don't know =

>>> how...
>>>
>>> Thank a lot
>>> -Will
>>> BTW thanks for the debugging stuff earlier. Got that workin...
>>



-- =

Using Opera's revolutionary e-mail client: http://www.opera.com/mail/

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация