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
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. 

Link to comment
Share on other sites

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 ^

Edited by Beeeeney
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.