Set default value for select input in php -


i want set default value @ "-24hours". options dynamically generated foreach.

<select id="search3" name="date" onchange='this.form.submit();'>     <?php         $orderby_options3 = array(             '-3day' => 'last 3 days',             '-48hours' => '48 hours',             '-24hours' => '24 hours',         );         foreach( $orderby_options3 $value3 => $label3 ) {             echo "<option ".selected( $_get['date'], $value3 )." value='$value3'>$label3</option>";         }     ?> </select> 

i know should add "selected" parameter option in case, it's not possible.

if want -24hours selected , page won't used edit page, can this:

<select id="search3" name="date" onchange='this.form.submit();'> <?php     $orderby_options3 = array(         '-3day' => 'last 3 days',         '-48hours' => '48 hours',         '-24hours' => '24 hours',     );      foreach( $orderby_options3 $value3 => $label3 ) {         $select = ($value3 == '-24hours') ? "selected='selected'":""; // see line         echo "<option ".selected( $_get['date'], $value3 )." value='$value3' $select>$label3</option>";     } ?> 


Comments

Popular posts from this blog

ubuntu - PHP script to find files of certain extensions in a directory, returns populated array when run in browser, but empty array when run from terminal -

php - How can i create a user dashboard -

javascript - How to detect toggling of the fullscreen-toolbar in jQuery Mobile? -