?
Solved

Displaying user selection on the same page

Posted on 2003-03-29
3
Medium Priority
?
149 Views
Last Modified: 2013-12-24
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?
0
Comment
Question by:TriggerFish
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 12

Accepted Solution

by:
jyokum earned 90 total points
ID: 8230531
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)>
</cfif>

<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>
     </select>
     <input type="submit" value="Add Item">
     <input type="hidden" name="valueList" value="<cfoutput>#myList#</cfoutput>">
</form>
<table border="1">
     <cfoutput>
     <cfloop from="1" to="#ListLen(myList)#" index="item">
     <tr>
          <td>#listgetat(myList,item)#</td>
     </tr>
     </cfloop>
     </cfoutput>
</table>


0
 

Author Comment

by:TriggerFish
ID: 8230601
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"
     name="valueList"
     value="<cfoutput>#myList#</cfoutput>">

Thanks again.

0
 
LVL 12

Expert Comment

by:jyokum
ID: 8230730
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#</cfoutput>

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.
0

Featured Post

What Is Blockchain Technology?

Blockchain is a technology that underpins the success of Bitcoin and other digital currencies, but it has uses far beyond finance. Learn how blockchain works and why it is proving disruptive to other areas of IT.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This is a guide to setting up a new WHM/cPanel Server to be used for web hosting accounts. It is intended for web hosting company administrators and dedicated server owners. For under $99 per month (considering normal rate of Big Data Cetnters like …
Meet the world's only “Transparent Cloud™” from Superb Internet Corporation. Now, you can experience firsthand a cloud platform that consistently outperforms Amazon Web Services (AWS), IBM’s Softlayer, and Microsoft’s Azure when it comes to CPU and …
In this video we outline the Physical Segments view of NetCrunch network monitor. By following this brief how-to video, you will be able to learn how NetCrunch visualizes your network, how granular is the information collected, as well as where to f…
How to fix incompatible JVM issue while installing Eclipse While installing Eclipse in windows, got one error like above and unable to proceed with the installation. This video describes how to successfully install Eclipse. How to solve incompa…

752 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question