Solved

Reference value within Form page (as opposed to Action page)

Posted on 2004-10-14
6
189 Views
Last Modified: 2013-12-20
ColdFusion 5.0

<td bgcolor="eeeeee"> <cfselect size="1" name="PayMethod">
                <option selected value="Invoice">Renewal</option>
                <option value="Credit Card">Credit Card</option>
              </cfselect> </td>

I wish to reference the value within the current page so as to determine what other code to display.  All of my research on the net results in FORM.#paymethod# but I need the value before it is passed to the Action page.

thx!
0
Comment
Question by:neiljstandley
[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
  • 3
  • 2
6 Comments
 
LVL 7

Expert Comment

by:black0ps
ID: 12313549
#Evaluate("Form." & paymethod)#
0
 

Author Comment

by:neiljstandley
ID: 12314009
<td bgcolor="eeeeee"> <cfselect size="1" name="PayMethod">
                <option selected value="Invoice">Renewal</option>
                <option value="Credit Card">Credit Card</option>
              </cfselect> </td>
          </tr>
<cfif #Evaluate("Form." & paymethod)# is "Credit Card">

runtime:
Error resolving parameter PAYMETHOD

ColdFusion was unable to determine the value of the parameter. This problem is very likely due to the fact that either:

You have misspelled the parameter name, or
You have not specified a QUERY attribute for a CFOUTPUT, CFMAIL, or CFTABLE tag.
-----------------------------------------------
Paymethod is the correct name, the action page inserts data to the DB w/the same name.  
0
 
LVL 7

Accepted Solution

by:
black0ps earned 50 total points
ID: 12314027
I need to back up a second. I reread your question and i think I know what you mean. What you actually want is Javascript or client-side code, not server-side.

<script language="JavaScript">
<!--
function displayStuff(x) {      
      x = document.pay.PayMethod.options[x].value;
      if (x == "Invoice") {
            document.getElementById('invoice').style.display = "block";
            document.getElementById('card').style.display = "none";
      }
      else if (x == "Credit Card") {
            document.getElementById('invoice').style.display = "none";
            document.getElementById('card').style.display = "block";
      }
}
//-->
</script>
<form name="pay">
<select size="1" name="PayMethod" onChange="displayStuff(this.options.selectedIndex)">
<option value="Invoice">Renewal</option>
<option value="Credit Card">Credit Card</option>
</select>

<div id="invoice">Invoice code</div>
<div id="card" style="display:none;">Credit Card code</div>
</form>
0
Three Reasons Why Backup is Strategic

Backup is strategic to your business because your data is strategic to your business. Without backup, your business will fail. This white paper explains why it is vital for you to design and immediately execute a backup strategy to protect 100 percent of your data.

 
LVL 35

Expert Comment

by:mrichmon
ID: 12314034
Really all you need is

Form.Paymethod

<cfif Form.Paymethod EQ "Credit Card">
...
</cfif>

But that is after the form is submitted.

If you want the value before the form is submitted you need javascript.

if(document.yourformname.paymethod.value == "Credit Card")
{
alert("You selected credit card!");
}
0
 

Author Comment

by:neiljstandley
ID: 12314093
going to give these a try tomorrow, thx for the tips.
0
 

Author Comment

by:neiljstandley
ID: 12341182
thx, that worked great for me.  guess it's time i start looking into javascript!
0

Featured Post

Business Impact of IT Communications

What are the business impacts of how well businesses communicate during an IT incident? Targeting, speed, and transparency all matter. Find out more in this infographic.

Question has a verified solution.

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

When setting up new project requests for our site, one of the most powerful tools our team has available to use is Axure (http://www.axure.com/). It’s a tool for creating software and web prototypes that can function and interact as if it were the a…
Introduction This article explores the design of a cache system that can improve the performance of a web site or web application.  The assumption is that the web site has many more “read” operations than “write” operations (this is commonly the ca…
The purpose of this video is to demonstrate how to properly insert a Vimeo Video into a WordPress site or Blog. This will be demonstrated using a Windows 8 PC. Go to your WordPress login page. This will look like the following: mywebsite.com/wp…
The purpose of this video is to demonstrate how to set up the permalinks on a WordPress Website. This will be demonstrated using a Windows 8 PC. Go to your WordPress login page. This will look like the following: mywebsite.com/wp-login.php : Go t…

734 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