url parameter question

Posted on 2005-05-05
Medium Priority
Last Modified: 2013-12-24
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.

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

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


<input type="button" name="SubmitForm" value="Find" onClick="this.form.submit()">
Question by:indypung
LVL 10

Expert Comment

ID: 13936272

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

      <form action="page2.cfm?#cgi.QUERY_STRING#" method="post">

Expert Comment

ID: 13937304
you could do something like this
<cfparam name="URL.IncidentNumber" type="string" default=''>

<cfif isdefined('form.IncidentNumber')>
     <cfset URL.IncidentNumber=form.IncidentNumber>
LVL 20

Expert Comment

ID: 13937754
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...


Get expert help—faster!

Need expert help—fast? Use the Help Bell for personalized assistance getting answers to your important questions.


Accepted Solution

andw928 earned 200 total points
ID: 13948396
Well you can pass it in the form when the form is submitted in the action attribute like this:

page1 -> Links to page2 with: edit.cfm?IncidentNumber=#GetSingleIncident.INCIDENT_NUMBER#

Then on page2 you would submit the form to itself, so you would do this:


    <form method="post" action="edit.cfm?IncidentNumber=#url.IncidentNumber#">
        ...the rest of your forms go here


Author Comment

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


Expert Comment

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


Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Periodically we have to update or add SSL certificates for customers. Depending upon your hosting plan you may be responsible for the installation and/or key generation. In the wake of Heartbleed many sites were forced to re-key. We will concen…
When it comes to security, close monitoring is a must. According to WhiteHat Security annual report, a substantial number of all web applications are vulnerable always. Monitis offers a new product - fully-featured Website security monitoring and pr…
When cloud platforms entered the scene, users and companies jumped on board to take advantage of the many benefits, like the ability to work and connect with company information from various locations. What many didn't foresee was the increased risk…
Enter Foreign and Special Characters Enter characters you can't find on a keyboard using its ASCII code ... and learn how to make a handy reference for yourself using Excel ~ Use these codes in any Windows application! ... whether it is a Micr…
Suggested Courses

609 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