TriggerFish
asked on
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?
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?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
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.
example:
<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" --->
<cfoutput>#myList#</cfoutp ut>
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.
listappend just takes an existing list, in this case myList, and adds a new value to the end of the list.
example:
<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" --->
<cfoutput>#myList#</cfoutp
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.
ASKER
<cfparam name="myList" default="">
why <cfset myList = listappend(myList,form.val
<cfset myList = listappend(myList,form.thi
and <input type="hidden"
name="valueList"
value="<cfoutput>#myList#<
Thanks again.