[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

Replace variable value instead of adding to value string?

Posted on 2007-08-08
2
Medium Priority
?
177 Views
Last Modified: 2013-12-24
I have a form that sets a variable from the select and when submitted, outputs the variable value so I can see what it is.  Problem is that every time the select list is chosen, it doesn't REPLACE the variable value, it just ADDS it to the list!  

Example: If I select 1, (submits), I get result of "1".  Then select 8, (submits),  and I get "1,8".  Then 14, (submits) then I get "1,8,14 " as the result.  I WANT to get "1", then "8", then "14" so that every time I select, it REPLACES the value instead of adding to the string.

How do I make it replace the value?  Essential code follows: (rsUnits result set has values 1-35)

<cfparam name="Form.UnitSelected" default="00">

<cfif isdefined ("Form.UnitSelected")>
<cfset UnitSelected ="#Form.UnitSelected#">
</cfif>

Variable UnitSelected: <cfoutput>#Variable.UnitSelected#</cfoutput>

<form method="post" action="Unit.cfm">
<input type="hidden" name="UnitSelected" value="<cfoutput>#Form.UnitSelected#</cfoutput>" />      
Unit:
<select name="UnitSelected" onchange="this.form.submit();">
      <option value="">ALL</option>
      <cfoutput query="rsUnits">
      <option value="#rsUnits.UnitID#"<cfif #rsUnits.UnitID# EQ #Form.UnitSelected#>selected="selected"</cfif>>#rsUnits.UnitID#</option>
      </cfoutput>
</select>
</form>

0
Comment
Question by:Upekrithen
2 Comments
 
LVL 14

Accepted Solution

by:
Scott Bennett earned 2000 total points
ID: 19657213
Just take out the hidden field
<input type="hidden" name="UnitSelected" value="<cfoutput>#Form.UnitSelected#</cfoutput>" />      
or give it a new name that is different than the select box. When you have to fields named the same they will show up as a list in you form scope
0
 

Author Comment

by:Upekrithen
ID: 19657778
Right ON!  What a minor change with enormous effect.  Thanks a bunch!  I've been beating my head against the wall trying four million things to find that oh-so-close but elusive (and simple) solution.  Danka.
0

Featured Post

Vote for the Most Valuable Expert

It’s time to recognize experts that go above and beyond with helpful solutions and engagement on site. Choose from the top experts in the Hall of Fame or on the right rail of your favorite topic page. Look for the blue “Nominate” button on their profile to vote.

Question has a verified solution.

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

This article explains how to prepare an HTML email signature template file containing dynamic placeholders for users' Azure AD data. Furthermore, it explains how to use this file to remotely set up a department-wide email signature policy in Office …
Today, the web development industry is booming, and many people consider it to be their vocation. The question you may be asking yourself is – how do I become a web developer?
In this tutorial viewers will learn how to embed Flash content in a webpage using HTML5. Ensure your DOCTYPE declaration is set to HTML5: "<!DOCTYPE html>": Use the <object> tag to embed Flash content.: To specify that the object is Flash content, d…
In this tutorial viewers will learn how to embed videos in a webpage using HTML5. Ensure your DOCTYPE declaration is set to HTML5: "<!DOCTYPE html>": Use the <video> tag to insert a video. Define the src as the URL of your video; this is similar to …
Suggested Courses

873 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