Populate and assign a variable to a selection in a drop down (listbox).

Simple question of creating a list of 4 items (apple, orange, grape,  kiwi) and once the user selects which one, set a variable $fruit to it.  Please help by a coding example.
Thank you,

Who is Participating?
venkateshwarrConnect With a Mentor Commented:
Something like this?

      $fruit = $_REQUEST['fruits'];
      print "fruit = $fruit";


<form name='fruitselection' method='get'>
<select name='fruits' onchange="document.forms['fruitselection'].submit();">
<option value='apple'> apple
<option value='orange'> orange
<option value='grape'> grape
<option value='kiwi'> kiwi
<input type="submit">
RUSS_EMIAuthor Commented:
Something exactly like that.  Please let me try it out in a few days (I'm traveling now) and I'll be glad to award the points if it is works as I think it will.
Thank you,
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.