Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

Passing varaibles to next page

Posted on 2000-03-01
15
225 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
ID: 2574209
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
ID: 2574262
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
ID: 2574264
have you tried using

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


instead of
<cfset FirstField=#url.Pm1#>
 <cfset SecondField=#url.Pm2#>
0
Easy, flexible multimedia distribution & control

Coming soon!  Ideal for large-scale A/V applications, ATEN's VM3200 Modular Matrix Switch is an all-in-one solution that simplifies video wall integration. Easily customize display layouts to see what you want, how you want it in 4k.

 
LVL 1

Expert Comment

by:bigbadb
ID: 2574286
bigbadb changed the proposed answer to a comment
0
 
LVL 1

Expert Comment

by:bigbadb
ID: 2574288
oops didnt mean to post as answer
 
sorry
0
 
LVL 4

Expert Comment

by:FRehman
ID: 2575589
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
ID: 2575856
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
 
LVL 1

Expert Comment

by:deepchanda
ID: 2576566
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
ID: 2582046
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
ID: 2584789
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
ID: 2584791
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
ID: 2589869
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
ID: 2590801
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
ID: 2591592
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
ID: 2591826
Use the session variables
0

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

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…
Lease-to-own eliminates the expenditure of hardware replacement and allows you to pay off the server over time. Usually, this is much cheaper than leasing servers. Think of lease-to-own as credit without interest.
Microsoft Active Directory, the widely used IT infrastructure, is known for its high risk of credential theft. The best way to test your Active Directory’s vulnerabilities to pass-the-ticket, pass-the-hash, privilege escalation, and malware attacks …
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…

809 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