Page 1 of 1

Php code to remember drop down selection

Posted: Sun Dec 31, 2006 1:55 pm
by kingdbag
Hey guys,

I've been trying to find some php code that will remember what selection I made on a drop down box on a previous html page and automatically have it selected on the next page. Im just posting from test.html to test.html but I want the combo selection that I made on the first page to still be selected on the next page after the post...can this even been done with php?

thanks!

Posted: Sun Dec 31, 2006 2:41 pm
by wildwobby
You can use use SESSION vars

Posted: Sun Dec 31, 2006 6:45 pm
by Crazy Coder
you can send it in POST method or GET (via Java Script)

Posted: Mon Jan 01, 2007 6:37 pm
by kingdbag
yea im not having problems sending the selection info I just want the drop down to be whatever selection i made so i don't have to use the drop down again to select the same item.

Anyone have a sample I can't seem to figure this out and im starting to angry because this doesn't seem that hard hahaha.... :evil:

Posted: Mon Jan 01, 2007 6:50 pm
by brendandonhue
echo the "SELECTED" attribute into the <option> tag for the one you want selected.

Posted: Mon Jan 01, 2007 11:51 pm
by neel_basu
Save It as Some_filename.html
==============================

Code: Select all

.................................................
<form method="GET" action="rcv.php">
  <select name="sel">
    <option>op1</option>
    <option>op2</option>
  </select>
  <input type="Submit" value="submit">
</form>
................................................
Save it As rcv.php
=========================

Code: Select all

<?php
echo $_GET['sel'];
?>
EDIT|OOPS forgot to put </option>

Posted: Tue Jan 02, 2007 12:08 am
by feyd
missing </option>

...

yes, it's required.

Posted: Tue Jan 02, 2007 12:12 am
by neel_basu
Ya You are Right
OOPS I forgot To do It

Posted: Tue Jan 02, 2007 11:39 am
by kingdbag
Thanks guys think i got it.....i'll let you know and post the code just incase anyone else ever needs the samething or similar....

Thanks!