Link to home
Start Free TrialLog in
Avatar of indypung
indypung

asked on

url parameter question

i think this is pretty simple, but i've been struggling with it for awhile so i figured i'd ask for some help.  my problem is this.  i have a coldfusion page, page1.cfm, that passes a url parameter to a second coldfusion page, page2.cfm.  i'm getting the value passed over fine.   my problem is that page2.cfm submits to itself.  when it submits to itself, i get an error that url.incidentnumber is not defined.  how can i store the value of url.incidentnumber when page1.cfm sends it to page2.cfm, but not attempt to read it when page2.cfm submits to itself?  thanks.

page1.cfm
<a href="Edit.cfm?IncidentNumber=#GetSingleIncident.INCIDENT_NUMBER#">EDIT</a>

page2.cfm
<cfparam name="URL.IncidentNumber" type="string">

...

<input type="button" name="SubmitForm" value="Find" onClick="this.form.submit()">
Avatar of rob_lorentz
rob_lorentz


cgi.query_string contains all the url parameters passing into a page. in page1.cfm add them to the form that posts to page2

<cfoutput>
      <form action="page2.cfm?#cgi.QUERY_STRING#" method="post">
</cfoutput>
you could do something like this
<cfparam name="URL.IncidentNumber" type="string" default=''>

<cfif isdefined('form.IncidentNumber')>
     <cfset URL.IncidentNumber=form.IncidentNumber>
</cfif>
The problem is the value on your second page isn't defined, there's a few ways to solve your issue, rob_lorentz, CFDevHead, already provided something that would work, but I thought I'd throw my 2cents in.

Another way i... add a hidden field..

<cfinput type="hidden" name="IncidentNumber" value="#form.IncidentNumber#">

this will then define and retain that value...

~trail

ASKER CERTIFIED SOLUTION
Avatar of andw928
andw928

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
Avatar of indypung

ASKER

all good answers.  i awarded points to the one i chose to use.  thanks for all for your help.

bp
Np, if you have any more questions or if something isn't working, just post below and I will continue answering them.

-Matt