Jump to content

Recommended Posts

guys i need help,

i got 2 page, 1 for the form and 1 for the sendmail

this is the link for my form
http://www.banyantree.com/earthday/eform.php
and this is the link for my sendmail
http://www.banyantree.com/earthday/sendmail.php

i was able to solve my previous problem here regarding my checkbox

now my new problem is this:
when i select the resort from the form
what i want to happen there is when i select it
it will remain selected instead of going back to my default selected item which is bangkok.
hope you're getting what i mean.

this is an easy problem but i can't find the solution, hope you could help me with this.
this is the code for my drop down:
[code]<?
if (!isset($_GET['url'])){
  $url='bangkok.php';
} else {
  $url = $_GET['url'];
}
?>

<select class="sorteventlist" name="list" onFocus="selectedIndex = 0" onChange="if( options[selectedIndex].value != '') document.location = 'eform.php?url='+form.list.value">
  <option value="bangkok.php">Banyan Bangkok</option>
  <option value="bintan.php">Banyan Tree Bintan</option>
  <option value="lijiang.php">Banyan Tree Lijiang</option>
  <option value="maldives.php">Banyan Tree Maldives</option>
  <option value="phuket.php">Banyan Tree Phuket</option>
  <option value="ringha.php">Banyan Tree Ringha</option>
  <option value="seychelles.php">Banyan Tree Seychelles</option>
              </select>
<br><br>
<? include ($url); ?>

[/code]

thanks!

Link to comment
https://forums.phpfreaks.com/topic/36153-need-help-on-my-drop-down-list/
Share on other sites

Put everything in an array, and then preform some checks. This way:

[code]<?php
$url = (!isset($_GET['url'])) ? 'bangkok.php' : $_GET['url'];

$dropdown = array("bangkok.php" => "Banyan Bangkok", "bintan.php" => "Banyan Tree Bintan", "lijiang.php" => "Banyan Tree Lijiang", "maldives.php" => "Banyan Tree Maldives", "phuket.php" => "Banyan Tree Phuket", "ringha.php" => "Banyan Tree Ringha", "seychelles.php" => "Banyan Tree Seychelles");

echo "<select class=\"sorteventlist\" name=\"list\" onFocus=\"selectedIndex = 0\" onChange=\"if( options[selectedIndex].value != '') document.location = 'eform.php?url='+form.list.value\">\n";
foreach($dropdown as $link => $text)
{
echo "<option value=\"".$link."\"";
if($link == $url)
echo " selected";
echo ">".$text."</option>";
}
echo "</select>";
echo "<br><br>\n";

include ($url);

?>[/code]

Orio.
This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.