Passing varaibles to next page

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.
cb1Asked:
Who is Participating?
 
pdlilesCommented:
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
 
deepchandaCommented:
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
 
bigbadbCommented:
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
Introducing Cloud Class® training courses

Tech changes fast. You can learn faster. That’s why we’re bringing professional training courses to Experts Exchange. With a subscription, you can access all the Cloud Class® courses to expand your education, prep for certifications, and get top-notch instructions.

 
anushaCommented:
have you tried using

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


instead of
<cfset FirstField=#url.Pm1#>
 <cfset SecondField=#url.Pm2#>
0
 
bigbadbCommented:
bigbadb changed the proposed answer to a comment
0
 
bigbadbCommented:
oops didnt mean to post as answer
 
sorry
0
 
FRehmanCommented:
you have mistake in this line write in that way
<a href="../Page2.cfm?Pm1=#Form.FieldName#&Pm2=5">Click here</a>
0
 
cb1Author Commented:
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
 
deepchandaCommented:
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
 
carehartCommented:
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
 
pdlilesCommented:
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
 
beregothCommented:
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
 
cb1Author Commented:
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
 
pdlilesCommented:
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
 
smuniasamyCommented:
Use the session variables
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.