Jump to content

Form Stickyness Not Working


thara

Recommended Posts

hi.. can anybody tell me what is the wrong with this code....?

 

  <?php
   // array for tution option for searching
   $findOptions = array( 1 => 'Private Tutors', 'Tutorial Centers', 'Individual Classes', 'Group Classes', 'Online Classes', 'Study Packs');

   // Make the find tution option drop down menu
   echo '<label><select name="search_option">';
   foreach ($findOptions as $key => $value) {
    echo '<option value="'. $key . '"' ;

    // Check for stickyness:
    if ( isset( $_POST['search_option']) && $_POST['search_option'] == $value )
	 echo ' selected="selected"';

    echo " >$value</option>\n";
   }
   echo '</select></label>';	  
  ?>

 

I am trying to make this select box to stickness.. but it is not working..

 

thanks

Link to comment
https://forums.phpfreaks.com/topic/270083-form-stickyness-not-working/
Share on other sites

echo '<option value="'. $key . '"' ;
           
                // Check for stickyness:
                if ( isset( $_POST['search_option']) && $_POST['search_option'] == $value )
                 echo ' selected="selected"';
           
                echo " >$value</option>\n";

 

I would assume that $_POST['search_option'] would match $key, not $value. 

I'm not 100% sure how you'd go about doing it but I'm sure it involves sessions, cookies, writing to a database and then pulling the same information from the database next time, based on the cookie.

 

That's how I'd do it, anyway.

 

Edit: What they said ^

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.