Displaying user selection on the same page

Dear Experts,

I have a form with a drop down menu box populated from a query from the database with a add button. When the user selects the item from the drop down box and clicks add, I want to display the selected item on the same page (showing the user what he/she has selected), after which the user can make other selections using the same drop down menu box and add the selection which will be appended below what he/she has added on earlier.

How can I do this?
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

This refreshes the page everytime but should work:

<cfparam name="form.valueList" default="">
<cfparam name="myList" default="">
<cfif isdefined("form.things")>
     <cfset myList = listappend(myList,form.valueList)>
     <cfset myList = listappend(myList,form.things)>

<form name="frmAdd" action="add.cfm" method="post">
     <select name="things">
          <option value="this">this</option>
          <option value="that">that</option>
          <option value="the other">the other</option>
     <input type="submit" value="Add Item">
     <input type="hidden" name="valueList" value="<cfoutput>#myList#</cfoutput>">
<table border="1">
     <cfloop from="1" to="#ListLen(myList)#" index="item">


Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
TriggerFishAuthor Commented:
Thanks, it work perfectly are you able to disect the code so as to give a short explaination on how it work? Like why <cfparam name="form.valueList" default="">
    <cfparam name="myList" default="">

why <cfset myList = listappend(myList,form.valueList)>
    <cfset myList = listappend(myList,form.things)>

and <input type="hidden"

Thanks again.

After looking at it again, the cfparam's are not necessary. They could be replaced with <cfset myList="">.

listappend just takes an existing list, in this case myList, and adds a new value to the end of the list.
<cfset myList=""> <!--- you need this because listappend requires that the list your appending to already exists --->
<cfset myList = listappend(myList,"A")>
<!--- myList now = "A" --->
<cfset myList = listappend(myList,"B")>
<!--- myList now = "A,B" --->

the hidden form field just stores our list so that when another item is added, we have the previous selections.

here's the logic:
if the form has been submitted, add all the values previously in the list (form.valueList) and the new value (form.thing) to a new list (myList). Then store the new list in a hidden field (valueList) for the next time the form is submitted.
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Web Servers

From novice to tech pro — start learning today.

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.