Go Back  HTML Forums - Free Webmaster Forums and Help Forums > WEBSITE DEVELOPMENT > Server Side Programming > PHP Programming
User Name:
Password:
 

Reply
Thread Tools   Display Modes
  View First Unread
 
Old 05-10-2008, 11:43 PM
  #1
Jupitertrooper
Aspirant (Level 2)
 
Join Date: Apr 2008
Posts: 19
iTrader: (0)
Jupitertrooper is an unknown quantity at this point
php/drop down menu

I am creating a drop down menu using php and html. When the user selects the drop down item and clicks go, I want the page to go to the link I put in the options.

I think it will work though I cant be sure because I get this message when I try using the drop down menu(I am using Uniform Server)

Forbidden You don't have permission to access /< on this server.
What does that mean? Anyway, here is my code:

<?php
$s=$_POST["option"];
?>
<html>
<title>Dropdown Test</title>
<form method="post" action="<?php $s ?>">
<select name="option">
<option value="option1.html">
Option1
</option>
<option value="option2.html">
Option2
</option>
<option value="option3.html">
Option 3
</option>
<option value="option4.html">
Option4
</option>
</select>
<input type="submit" value="GO">
</form>
</html>

So would this work? I know the dropdown part is right, just making the GO take the user to the file that is selected is my problem.

Last edited by Jupitertrooper : 05-10-2008 at 11:55 PM. Reason: change of code
Jupitertrooper is offline   Add to del.icio.us Add to del.icio.us    Can you digg it?Can you digg it? Reply With Quote
Old 05-11-2008, 01:57 AM
  #2
Horus_Kol
Mod of the Underlay
 
Horus_Kol's Avatar
 
Join Date: Jun 2002
Location: At a desk, hooked up and ready to rock
Posts: 16,213
iTrader: (0)
Horus_Kol is a jewel in the roughHorus_Kol is a jewel in the roughHorus_Kol is a jewel in the roughHorus_Kol is a jewel in the rough
you're mixing up the serverside with clientside here...

when you first request the form, there is no POST data, and so $s is initialised to null (actually, you should be seeing an error about an undefined index if you have STRICT error messages set)

so, the form action is set to '' - which is wrong, as you can see...


You could use a javascript to do this:

HTML Code:
<script type="text/javascript">
  function submit_form()
  {
    var file_select = document.getElementById('file_select');

    if (file_select.selectedIndex > -1) {
      var test_form = document.getElementById('dropdown_test_form');

      test_form.action = file_select.options[file_select.selectedIndex].value;

      test_form.submit();
    }
  }
</script>

<form id="dropdown_test_form" method="post" action="option1.html">
  <select name="option" id="file_select">
    <option value="option1.html">
      Option1
    </option>
    
    <option value="option2.html">
      Option2
    </option>  
  </select>
</form>
Horus_Kol is offline   Add to del.icio.us Add to del.icio.us    Can you digg it?Can you digg it? Reply With Quote
Old 05-11-2008, 12:13 PM
  #3
Jupitertrooper
Aspirant (Level 2)
 
Join Date: Apr 2008
Posts: 19
iTrader: (0)
Jupitertrooper is an unknown quantity at this point
ok, thanks, I thought it would work with PHP but I guess I was wrong.
Jupitertrooper is offline   Add to del.icio.us Add to del.icio.us    Can you digg it?Can you digg it? Reply With Quote
Old 05-11-2008, 06:49 PM
  #4
Horus_Kol
Mod of the Underlay
 
Horus_Kol's Avatar
 
Join Date: Jun 2002
Location: At a desk, hooked up and ready to rock
Posts: 16,213
iTrader: (0)
Horus_Kol is a jewel in the roughHorus_Kol is a jewel in the roughHorus_Kol is a jewel in the roughHorus_Kol is a jewel in the rough
well - PHP only runs on the server after a request... so it can't detect changes on the client until after the next request.
Horus_Kol is offline   Add to del.icio.us Add to del.icio.us    Can you digg it?Can you digg it? Reply With Quote
Reply
« Previous Thread | Next Thread »


 
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
  
 
 
 



 
  POSTING RULES
 
 
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Thread Tools
Display Modes

Forum Jump

 

All times are GMT -5. The time now is 11:02 AM.

   

Mascot team created by Drawshop.com

Powered by vBulletin® Version 3.6.7
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.

Server Monitoring by ENIACmonitor 0.01
HTMLforums.com © Big Resources, Inc. Web Design by BoxedArt.com
vRewrite 1.5 beta SEOed URLs completed by Tech Help Forum and Chalo Na.