Solved

Passing varaibles to next page

Posted on 2000-03-01
15
192 Views
Last Modified: 2013-12-24
I have session variables set on in application.cfm. On my first page I have the following:

<a href"../Page2.cfm?Pm1=#Form.FieldName#&Pm2=5">Click here</a>

On my second page I have the following:

<cfset FirstField=#url.Pm1#>
<cfset SecondField=#url.Pm2#>

I get the error message: Error resolving parameter...

Can anyone help? Thanks.
0
Comment
Question by:cb1
  • 3
  • 3
  • 2
  • +6
15 Comments
 
LVL 1

Expert Comment

by:deepchanda
Comment Utility
first, is the page having #Form.FieldName# called from another page, otherwise if the form is on the same page, just use javascript to pass the value of that to the next page. #Form.FieldName# would be available only if you are on the page that gets called from the page that has that particular form.

Your code should look like

<script>

function callpage() {
  window.location.href = '../Page2.cfm?Pm1=' + document.formname.element.value + '&Pm2=5';
}
 
</script>

<a href="" onClick="callpage()">Click here</a>

this would pass the value of that form element as Pm1 to the next page as a url var. hope this helps

DC
0
 
LVL 1

Expert Comment

by:bigbadb
Comment Utility
YES it is nice to know where the form variable is coming it seems like it is coming from the first page.  If so you have to reference it as deepchada stated above if not you dont.  You cantry to take the part out of your url call

<a href"../Page2.cfm?Pm2=5">Click here</a>


THen on the other page only reference

<cfset SecondField=#url.Pm2#> this will allow you to test to see if you have the overall functionialty working

0
 

Expert Comment

by:anusha
Comment Utility
have you tried using

<cfset FirstField=#Pm1#>
<cfset SecondField=#Pm2#>


instead of
<cfset FirstField=#url.Pm1#>
 <cfset SecondField=#url.Pm2#>
0
 
LVL 1

Expert Comment

by:bigbadb
Comment Utility
bigbadb changed the proposed answer to a comment
0
 
LVL 1

Expert Comment

by:bigbadb
Comment Utility
oops didnt mean to post as answer
 
sorry
0
 
LVL 4

Expert Comment

by:FRehman
Comment Utility
you have mistake in this line write in that way
<a href="../Page2.cfm?Pm1=#Form.FieldName#&Pm2=5">Click here</a>
0
 

Author Comment

by:cb1
Comment Utility
The form is on the first page. I don't want to use Javascript to pass the parameter as it should be possible to do without. I think what I have should work but it doesn't seem to. I have tried:

<cfset secondfield=#url.pm2#>
<cfset secondfield="#url.pm2#">
<cfset secondfield=#pm2#>
0
What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

 
LVL 1

Expert Comment

by:deepchanda
Comment Utility
when u have something like <cfset secondfield=#pm2#>, CF app server while processing it, searches for all diff types of var to see if they exist, like weather they are form, url, cgi .... and retrieves the one thats existing. So in this case its url,. But to speed up processing its always good to have a prefix to expedite CF execution on the server side.

As far as you form var goes, it is provided by CF to sustain the values of a form to make it available on the next page that is been called. If the form is on the same page that you have the <a href> tag , then using javascript is the only u can have access to those form values.

DC
0
 
LVL 1

Expert Comment

by:carehart
Comment Utility
You say originally that "on your first page you have" a reference to #form.fieldname#. This variable will only be available when the page referring to it has been called as the action page of a form. As such, it can't be "on your first page".

Now, do you mean that it's the first page of the two you're mentioning--and it is the action page of a previous form? If so, are you executing it as a result of running it from the form? You would get an error on the page referring to the form field (even it it's an intended action page) if you didn't call it from a form.

Bottom line: you can't refer to a form field on a page unless that page is called from a form.
0
 

Accepted Solution

by:
pdliles earned 50 total points
Comment Utility
Carehart is quite right... to validate this, on your second page drop the first CFSET

<cfset FirstField=#url.Pm1#>

When you delete this, the error will go away because PM2 is a literal (i.e. you called it &Pm2=5

<cfset SecondField=#url.Pm2#>

BUT you will not get PM1 passed so....


If indeed the first page is a FORM page, then in the ACTION you should call the second page and pass the form fields.

To pass the "5" since it is apparently fixed use the following INSIDE the form tag somewhere.... When the form is submitted it becomes a FORMFIELD with a value of 5 name of PM2 but it does NOT show up to the user!

<INPUT TYPE="HIDDEN" NAME="PM2" VALUE=5>

When the form is passed to the second page, you do NOT need the URL variables as the values are contained in the form field..

AND

Change the CFSETS to be:

<cfset FirstField=#Form.Pm1#>
<cfset SecondField=#Form.Pm2#>


0
 

Expert Comment

by:pdliles
Comment Utility
One last comment...

You mentioned SESSIONVARIABLES in your question... for what you need here, SESSIONVARIABLES are not used!

If you indeed want to use session variables, you should use CFLOCK's
0
 
LVL 1

Expert Comment

by:beregoth
Comment Utility
I can't get over how many choices there are.  I don't have a helpful comment...I was just reading along and thought how wonderful a world we must live in to have access to all these people who know way way too much.  I feel so small....actually I just wanted to be notified of any changes in status because I am interested to see where this leads.  Is that rude of me?
0
 

Author Comment

by:cb1
Comment Utility
I'm currently evaluating all these choices! To clarify... I have a form page and an action page and want to pass the variables to the action page, however the form is selections to draw a chart (using cfxgraphics server), as the user can keep changing the selections and redrawing the chart I wanted to have the second page as a form and action page so the first page has default selections and the second page takes the users selections. Maybe I should split the page in to two frames with the form in the top half and action page in the second half?
0
 

Expert Comment

by:pdliles
Comment Utility
Why not sotre the DEFAULT SELECTIONS as a SESSION.VARIABLE and then let the user change that SESSION.VARIABLE until he/she is happy with it???

You would establish the default session variables in the application.cfm template.

Then call the form and use the SESION.VARIABLES as the default values.  Should the user want to modify these starting (default) positions, make the form page change the SESSION.VARIABLES.

Just an idea .. frames are such a pain in the rump!
0
 

Expert Comment

by:smuniasamy
Comment Utility
Use the session variables
0

Featured Post

Network it in WD Red

There's an industry-leading WD Red drive for every compatible NAS system to help fulfill your data storage needs. With drives up to 8TB, WD Red offers a wide array of solutions for customers looking to build the biggest, best-performing NAS storage solution.  

Join & Write a Comment

Suggested Solutions

This is a guide to setting up a new WHM/cPanel Server to be used for web hosting accounts. It is intended for web hosting company administrators and dedicated server owners. For under $99 per month (considering normal rate of Big Data Cetnters like …
Most ColdFusion developers get confused between the CFSet, Duplicate, and Structcopy methods of copying a Structure, especially which one to use when. This Article will explain the differences in the approaches with examples; therefore, after readin…
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.
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.

744 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

17 Experts available now in Live!

Get 1:1 Help Now