Link to home
Start Free TrialLog in
Avatar of TriggerFish
TriggerFish

asked on

Displaying user selection on same page - Part II

Dear Experts,

I have asked this question previously and had got an answer, but now I need to fullfill another requirement, that is the user will also be able to select the appended item and delete it from the list.

Can anyone help?


As Posted last time :
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
Avatar of JimV_ATL
JimV_ATL

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
I still had the code from your previous Q. Here's an update that adds the remove functionality.


<cfparam name="form.valueList" default="">
<cfparam name="myList" default="">
<cfif isdefined("form.things")>
     <cfset myList = form.valueList>
     <cfif len(form.removeList)>
          <cfset myList = listdeleteat(form.valueList,form.removeList)>
     <cfelse>
          <cfset myList = listappend(myList,form.things)>
     </cfif>
</cfif>

<script language="JavaScript">
function removeItem(itemNumber){
     document.frmAdd.removeList.value = itemNumber;
     document.frmAdd.submit();
}
</script>

<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>">
     <input type="hidden" name="removeList" value="">
<table border="1">
     <cfoutput>
     <cfloop from="1" to="#ListLen(myList)#" index="item">
     <tr>
          <td>#listgetat(myList,item)#</td>
          <td><a href="javascript:removeItem(#item#);">remove this item</a></td>
     </tr>
     </cfloop>
     </cfoutput>
</table>
</form>

Avatar of TriggerFish
TriggerFish

ASKER

I will close this question, both JimV and jyokum has given me good answers.

JimV's answer is close to what I am looking for, but jyokum has given me solutions which I can apply to other parts of my project.

Points wise, 25 to jyokum and 5 to JimV....any objections?

Thanks for all your help
TriggerFish,
You have requested a split that cannot be performed.  Each expert must receive a minimum of 20 points in a technical area.  Let me know how you would like to proceed.

SpideyMod
Community Support Moderator @Experts Exchange
OK, I have decided to give both experts 20 pts each.
Points reduced to 20.

You may now accept one expert's comment as the answer.

Next create a "points for expert2 re 20567868"(replace expert2 with the actual expert's name) question in this same Topic area:
https://www.experts-exchange.com/Web/WebDevSoftware/ColdFusion/
Assign 20 points to it.
Grab the URL of the new question (make sure it has the question number in it) and return here to tell the other expert where to get their points at.

If you need further help or the "points for" question isn't posted within a couple of days, somebody drop a note to me here.  Thanks.

SpideyMod
Community Support Moderator @Experts Exchange
TriggerFish, please accept a comment as the solution
I have performed the split.  Thanks for dropping a note here to alert me.

jyokum,points for you at:
https://www.experts-exchange.com/questions/20601209/points-for-jyokum-re-20567868.html

SpideyMod
Community Support Moderator @Experts Exchange