Jump to content

How to implement drop down list?


raysefo

Recommended Posts

Hi,

 

Lets say I have something like this ;

<select name="games" size="3">
<option value="1">game1</option>
<option value="2">game2</option>
</select>

I would like to select one of them from the list and get the value of the selected one. How can I do it?

 

Best Regards.

Try this:

<?php
if ($_POST['games']!='') echo '<h1>Last time you selected '.$_POST['games'].'</h1>'; 
?>
<form action="mypage.php" method="POST">
<p>Select a game:</p>
<select name="games" size="3">
<option value="1">game1</option>
<option value="2">game2</option>
</select>
<input type="submit">
</form>

save it as mypage.php and run it a couple of times to see how it works.

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.