Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Newbie: save a value from previous request

Status
Not open for further replies.

cadoltt

Programmer
Joined
Jun 9, 2005
Messages
85
Location
CA
Hi everybody,


My problem seems very basic but I don't know how solve it. There is a form which has a text field to input a value and a submit button, and the form action refers to the same template.

Besides the form the page displays two values: the entered one and [here I have troubles] the one entered before. And for the first time let's say the previous value should be "1".

Here is the code I'm playing around with:

Code:
<html>

  <head>
    <cfparam name = "curr_val" default = "1">
    <cfparam name = "prev_val" default = "1">

    <cfif IsDefined("frm_getValue.curr_val") is "True">
      <cfset prev_val = #curr_val#>
      <cfset curr_val = #form.curr_val#>
    </cfif>

  </head>

  <body>

    <cfoutput>Current value: #curr_val#</cfoutput>
    <br>
    <cfoutput>Previous value: #prev_val#</cfoutput>

    <br>
    <cfform name="frm_getValue" action="test.cfm" method="post">
      Enter value:
      <cfinput name="curr_val" type="text" size="5"></cfinput>
      then click  
      <input type="submit">
    </cfform>

  </body>

</html>


The problem with the code is that the previous value is always "1".

Can anyone help with this mess?


Thanks,

Alex
 
i think this is what you're looking for

Code:
<html>

  <head>
    <cfparam name = "form.curr_val" default = "1">
    <cfparam name = "form.prev_val" default = "1">

  </head>

  <body>

    <cfoutput>
	Current value: #form.curr_val#
    <br>
    Previous value: #form.prev_val#
	</cfoutput>

    <br>
    <cfform name="frm_getValue" action="test.cfm" method="post">
      Enter value:
      <cfinput name="curr_val" type="text" size="5">
	  <cfinput type="hidden" name="prev_val" value="#form.curr_val#">
      then click  
      <input type="submit">
    </cfform>

  </body>

</html>

=========================================
Don't sweat the petty things and don't pet the sweaty things.
 
NorthStarDA,


It works. How easy...


Thanks a lot!

Alex
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top