Jump to content

Get value from dropdown menu/list


Simonvetterli

Recommended Posts

Hi at All

 

I have the problem, that I do not know, how to get the value from the selected option in my dropdown list. Hope someone can help me. I have the follow code:

 

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>File Uploader</title>
<link href="css/reset.css" rel="stylesheet" type="text/css" />

<style type="text/css">
body {
	margin: 10px;
	font: 62% Tahoma, Arial, sans-serif;
}
#main_container{
	font-size: 1.4em;
}
h2 {
	font-size: 2em;
	padding-bottom: 20px;
}
</style>

<link href="css/ui-lightness/jquery-ui-1.8.14.custom.css" rel="stylesheet" type="text/css" />
<link href="css/fileUploader.css" rel="stylesheet" type="text/css" />

<script src="js/jquery-1.6.2.min.js" type="text/javascript"></script>
<script src="js/jquery-ui-1.8.14.custom.min.js" type="text/javascript"></script>
<script src="js/jquery.fileUploader.js" type="text/javascript"></script>

</head>

<body>
<div id="main_container">
	<h2>Bilder Girls Uploader</h2>
	<p> </p>
    <p>
      <?php
		mysql_connect("localhost:8888", "root", "root") or die("Connection Failed");
		mysql_select_db("mydb")or die("Connection Failed");
		$query = "SELECT idgirls,name FROM girls";
		$result = mysql_query($query);
	?>
      <form name="form1" method="POST" action="<?=$PHP_SELF?>">
      <select name="select1" onchange="this.form1.submit();" method="post">
        <?php
	while ($line = mysql_fetch_array($result, MYSQL_ASSOC)) {
	?>
        <option value="<?php echo $line['idgirls'];?>"> <?php echo $line['name'];?> </option>
        
        <?php
	}
	?>
      </select>
      </form>   
    </p>
    <p> </p>
    <p> </p>
	<form action="upload.php" method="post" enctype="multipart/form-data">
    <input type="file" name="userfile" class="fileUpload" multiple>
    <input type="hidden" name='girl' value='<?php echo $_POST['select1'];?>' />
		
		<button id="px-submit" type="submit">Upload</button>
		<button id="px-clear" type="reset">Clear</button>
</form>
	<script type="text/javascript">
		jQuery(function($){
			$('.fileUpload').fileUploader();
		});
	</script>
</div>
</body>
</html>

 

 

Link to comment
https://forums.phpfreaks.com/topic/276461-get-value-from-dropdown-menulist/
Share on other sites


               echo "<option value = ''>Select Category</option>";
               echo "<select name = 'cat_name'>";
	while($s = mysql_fetch_array($cat_class->get_the_result))
		  {
		echo "<option value = $s[cat_id]> $s[cat_name]</option>";
		   }
		echo "</select>";
		

 

a simple way, to get the record from database using select option, hope its help

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.