target HTML option label instead of its value in PHP? -


i trying target option label instead of value in php page.

i know php server side , difficult target option label there work around this?

the code using this:

    <!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>         <link rel="stylesheet" type="text/css" href=         "css/mainstyle_css.css" />         <meta http-equiv="content-type" content=         "text/html; charset=utf-8" />         <title>           title         </title>       </head>       <body>     <form method="post" action="">       <select name="mylist" id="mylist" class="mylist">         <optgroup label="list 1">     <option value="music/one" label="techno">techno</option>     <option value="music/two" label="rock">rock</option>      </optgroup>       </select>     <input type="submit" name="submit" id="submit" class="submit" value="search"/>      </form>       <?php echo $mylist; ?>        </body>  </html> 

with code above music/one , music/two echo-ed on php page. need echo labels "techno" , "rock".

could please me out this?

you this:

<?php $options = array(); $options["music/one"] = "techno"; $options["music/two"] = "rock"; ?>  <!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>         <link rel="stylesheet" type="text/css" href="css/mainstyle_css.css" />         <meta http-equiv="content-type" content="text/html; charset=utf-8" />         <title>title</title>     </head>     <body>         <form method="post" action="">             <select name="mylist" id="mylist" class="mylist">                 <optgroup label="list 1">                     <?php                     foreach($options $key => $value)                     {                         echo '<option value="'. $key .'" label="'. $value .'">'.$value.'</option>';                     }                     ?>                 </optgroup>             </select>             <input type="submit" name="submit" id="submit" class="submit" value="search"/>         </form>         <?php echo $options[$_post['mylist']]; ?>     </body> </html> 

Comments

Popular posts from this blog

java - Run a .jar on Heroku -

java - Jtable duplicate Rows -

validation - How to pass paramaters like unix into windows batch file -