pixeltrace Posted January 29, 2007 Share Posted January 29, 2007 guys i need help,i got 2 page, 1 for the form and 1 for the sendmailthis is the link for my form http://www.banyantree.com/earthday/eform.phpand this is the link for my sendmailhttp://www.banyantree.com/earthday/sendmail.phpi was able to solve my previous problem here regarding my checkboxnow my new problem is this:when i select the resort from the formwhat 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! Quote Link to comment https://forums.phpfreaks.com/topic/36153-need-help-on-my-drop-down-list/ Share on other sites More sharing options...
Orio Posted January 29, 2007 Share Posted January 29, 2007 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. Quote Link to comment https://forums.phpfreaks.com/topic/36153-need-help-on-my-drop-down-list/#findComment-171726 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.