url parameter question

Posted on 2005-05-05
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


    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">
    LVL 9

    Expert Comment

    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

    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...


    LVL 7

    Accepted Solution

    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

    LVL 1

    Author Comment

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

    LVL 7

    Expert Comment

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


    Featured Post

    Gigs: Get Your Project Delivered by an Expert

    Select from freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely and get projects done right.

    Join & Write a Comment

    Article by: kevp75
    Hey folks, 'bout time for me to come around with a little tip. Thanks to IIS 7.5 Extensions and Microsoft (well... really Windows 8, and IIS 8 I guess...), we can now prime our Application Pools, when IIS starts. Now, though it would be nice t…
    If you don't have the right permissions set for your WordPress location in IIS, you won't be able to perform automatic updates. Here's how to fix the problem.
    It is a freely distributed piece of software for such tasks as photo retouching, image composition and image authoring. It works on many operating systems, in many languages.
    Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.

    755 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

    Need Help in Real-Time?

    Connect with top rated Experts

    19 Experts available now in Live!

    Get 1:1 Help Now