问题描述:

i have seen several question but i can not find any answer?

i am add a some value to dropdown through the loop and want to show the value when i select one value from dropdown box .but i can not find .

 $items[] = $file ;

echo '<select name="value">';

foreach($items as $video){

echo '<option value="' . $video . '">' . $video . '</option>' ;

}

echo '</select>';

$value = $_GET['footage'];

How can I get the value when I select some value in the dropdown box.

网友答案:

You need to add HTML selected attribute to <select>

$value = $_GET['footage']; /* typo*/
 $items[] = $file ;
  echo '<select name="value">';
  foreach($items as $video){ 
    $selected = ($value == $video) ? 'selected="selected"' : '';
    echo  '<option value="' . $video . '"' . $selected . '>' . $video . '</option>' ;
  }

  echo'</select>';
相关阅读:
Top