Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 192
  • Last Modified:

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

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
neiljstandley
Asked:
neiljstandley
  • 3
  • 2
1 Solution
 
black0psCommented:
#Evaluate("Form." & paymethod)#
0
 
neiljstandleyAuthor Commented:
<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
 
black0psCommented:
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
Veeam Disaster Recovery in Microsoft Azure

Veeam PN for Microsoft Azure is a FREE solution designed to simplify and automate the setup of a DR site in Microsoft Azure using lightweight software-defined networking. It reduces the complexity of VPN deployments and is designed for businesses of ALL sizes.

 
mrichmonCommented:
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
 
neiljstandleyAuthor Commented:
going to give these a try tomorrow, thx for the tips.
0
 
neiljstandleyAuthor Commented:
thx, that worked great for me.  guess it's time i start looking into javascript!
0

Featured Post

Veeam and MySQL: How to Perform Backup & Recovery

MySQL and the MariaDB variant are among the most used databases in Linux environments, and many critical applications support their data on them. Watch this recorded webinar to find out how Veeam Backup & Replication allows you to get consistent backups of MySQL databases.

  • 3
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now