Jump to content


Photo

static combo box


  • Please log in to reply
2 replies to this topic

#1 nikhilthecool

nikhilthecool
  • Members
  • PipPip
  • Member
  • 18 posts

Posted 28 March 2006 - 02:02 PM

hi,

my code goes something like this..

<form action=samepage.php>
<select>
<option name="nick">nick
<option name="harry">harry
</select>
<input type=text name=msgbox>
.
.
.
<input type=submit name=submit>
</form>

its actly meant for selecting a user from the combo box and sending the message typed in the text field.
however, after i click send, the value of combo box resets to the first value...and i again have to select it from the box.

Isnt there any way that i can make the box static so that the next time i dont have to select the recepient of my msg..

Thanks.


#2 ober

ober
  • Staff Alumni
  • Advanced Member
  • 5,337 posts
  • LocationEast Coast, USA

Posted 28 March 2006 - 02:05 PM

That depends on how you use the form and what you want to do with it. If you just want to come back to the page and have the user selected again, you can set it from the $_POST/$_GET array, or you could set a cookie and pull it from that.

Once you have the value in a cookie or in the POST/GET super global array, all you have to do is create an option like this:

<option value="harry" selected="selected">harry</option>

Then just create your other options normally.

Info: PHP Manual


#3 nikhilthecool

nikhilthecool
  • Members
  • PipPip
  • Member
  • 18 posts

Posted 28 March 2006 - 02:37 PM

Hey ober,

The $_POST['....'] trick worked.

Great man...Thanks a lot.




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users