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

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

CF - Passin URL parameter to form

I am passing a URL parameter to be inserted to a table from a form.  All the values of the form are correctly being submitted to the table except the URL parameter.  When I hover over the link I do see the correct value that I am trying to pass.

 Any help is appreciated


This is the link to the form


<a rel="shadowbox;height=480;width=250" href="http://www.url.com/form/handouts-form.cfm?page=#$.content('title')#Handouts">SEND ME THE HANDOUTS</a>



Here is the form code



<cfif isDefined("URL.page")>
      <cfset pageName = URL.page />
      <cfelse>
            <cfset pageName = "none" />
</cfif>
<cfset message = "form" />

<cfif isDefined("FORM.submitData")>
      <cfquery datasource="data">
            INSERT INTO tbl_table
            (name, organization, email, Address1, Address2, City, State, Zip, Quantity, Page)

                    VALUES
                        (<cfqueryparam cfsqltype="CF_SQL_CHAR"  value="#FORM.name#">,
                      <cfqueryparam cfsqltype="CF_SQL_CHAR"  value="#FORM.organization#">,
                        <cfqueryparam cfsqltype="CF_SQL_CHAR"  value="#FORM.email#">,
                        <cfqueryparam cfsqltype="CF_SQL_CHAR"  value="#FORM.Address1#">,
                        <cfqueryparam cfsqltype="CF_SQL_CHAR"  value="#FORM.Address2#">,
                        <cfqueryparam cfsqltype="CF_SQL_CHAR"  value="#FORM.City#">,
                        <cfqueryparam cfsqltype="CF_SQL_CHAR"  value="#FORM.State#">,
                        <cfqueryparam cfsqltype="CF_SQL_CHAR"  value="#FORM.Zip#">,
                        <cfqueryparam cfsqltype="CF_SQL_CHAR"  value="#FORM.Quantity#">,
                        <cfqueryparam cfsqltype="CF_SQL_CHAR"  value="#FORM.Page#">
                       )
      </cfquery>
      <cfset pageName = #FORM.Page# />
      <cfset message = "thanks" />
</cfif>





The form

<form name="form" method="post" action="handouts-form.cfm" onSubmit="return submitIt(this)">
                  <input name="Page" type="hidden" id="Page" value="#pageName#" />
                  <label>Name:<br />
0
JohnMac328
Asked:
JohnMac328
  • 2
  • 2
1 Solution
 
billg7Commented:
I believe you need a <cfoutput> tag around your input. If I remember correctly, CF won't parse variables in standard html tags without it. so in the form section, try this:

 <form name="form" method="post" action="handouts-form.cfm" onSubmit="return submitIt(this)">
                  <cfoutput><input name="Page" type="hidden" id="Page" value="#pageName#" /></cfoutput>
                  <label>Name:<br />

Hope that helps!
0
 
_agx_Commented:
(no points ...)

<cfif isDefined("URL.page")>
      <cfset pageName = URL.page />
      <cfelse>
            <cfset pageName = "none" />
</cfif>

Side note, unless there's a good reason for it, I wouldn't create another "page" variable. It  just confuses things IMO. Just cfparam the variable and use it directly:

           <cfparam name="url.page" default="none">
           ...
          <input name="Page" type="hidden" id="Page" value="#url.page#" />
0
 
JohnMac328Author Commented:
Great - Thanks.

Thanks agx - great suggestion.  This was not my code and you are correct - it makes it much cleaner.
0
 
_agx_Commented:
Always interesting working w/somebody else's code. You're never sure if there was a clever reason for them doing X instead of Y ... or if they were just being lazy, lol.
0
 
JohnMac328Author Commented:
So true - :)
0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

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