Jump to content

Drop down menu With priority


bumdeal2

Recommended Posts

Hey guys im looking to do a drop down menu which is pretty basic however, in this drop down menu it uses an array of 4 values eg Orange, Apples, Bananas, Strawberry's. For this menu if a user has previously chosen an Orange which is stored on the db then then when the drop down menu is loaded it should move Orange to the top of the list, the same applies for the other values. How could I do this? I know how to do the select statement and place the values in an array. from there I dont know quite how to approach it.

 

 

Thank you.

 

 

Link to comment
Share on other sites

I see what you mean however I do not want to create another table and call the db as I feel it would be inefficient and would be more beneficial to not call the db, however I want the script so that for instance as I said the value they chose is stored on the db, as well as the different fruits. what would be the best way to within the  drop down menu to automatically assign the value previously chosen by the user as the first option and then display the other options available for them to change. without repeating the option chosen by the user again.

 

I could do the menu like so;

 

if($fruit == "Orange"){

<select name="Fruit" value="options">

<option value="Orange">Orange</option>

<option value="Apple">Apple</option>

<option value="Straw">Strawberry</option>

 

else if($fruit =="Apple"){

<option value ="Apple">Apple</option>

<option value="Orange">Orange</option>

<option value="Strawberry">Strawberry</option>

....................................

 

 

But personally I think thats highly inefficient coding where I should be able to just have one menu with all the data organised to match the users options... If you get me.

 

Thanks again for your help.

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.