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 bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Variables being displayed twice?

Status
Not open for further replies.

ma701sd

IS-IT--Management
Dec 15, 2000
94
GB
Hi,

I have a series of pages that are passing variables frm one page to another..In particular

Page 1 Recreates info from a database and is displayed. The variables are then being passed as hidden form fields to page 2 to populate the form with the variables from page 1.

Page 2 then passes to page 3 to display the form field variables.

The problem is that the variables are being displayed twice.

I reckon the problem is because the form fields is being passed to the third page while at the same time I am passing the same variables as hidden form fields to the third page.

The reason why I am using this approach is because if i dont use hidden form fields then page 3 reports an error saying it doesnt know what the variable is, but I'm passing via form fields...Whats going on?

Please help..

I have attached the code extracts for page 1,2,3

Page 1
<CFQUERY DATASOURCE= &quot;ONLINE&quot; NAME=&quot;RecreateUserPage&quot;>
SELECT *
FROM UserSpecific
WHERE Username= '#Client.username#'
</CFQUERY>

<!--- Querying the database and displaying the webpage the user created on a previous session stored in the DB --->
<CFOUTPUT QUERY= &quot;RecreateUSerPage&quot;>
<HTML>
<HEAD>
<TITLE>#title#</TITLE>
</HEAD>

<BODY>
<!--- Display PageHeading Variable --->
<CFIF #Headings1# NEQ &quot;&quot;> <#Headings1#></cfif>
<CFIF #Fonts1# NEQ &quot;&quot;> <Font Face=&quot;#Fonts1#&quot;></cfif>
<CFIF #Colours1# NEQ &quot;&quot;> <Font Color=&quot;#Colours1#&quot;></cfif>
<CFIF #HLine1# NEQ &quot;&quot;> <#Hline1#></cfif>
<!--- <CFSET Return1=#return#> --->
<CFLOOP Condition=&quot;#Return1# GT 0&quot;>
<BR>
<CFSET #Return1#=#Return1# - 1>
</CFLOOP>
#heading#
<CFIF #Headings1# NEQ &quot;&quot;> </#Headings1#></cfif>
<CFIF #Fonts1# NEQ &quot;&quot;> </Font></cfif>
<CFIF #Colours1# NEQ &quot;&quot;> </Font></cfif>
<CFIF #HLine1# NEQ &quot;&quot;> </#Hline1#></cfif>

Page2
<!--- Start HEADING Input --->
<B> Heading </b><BR>
<INPUT TYPE=&quot;Text&quot; NAME=&quot;Heading&quot; VALUE=&quot;#Heading#&quot;>
<BR>
<SELECT NAME =&quot;#headings1#&quot;>
<OPTION VALUE=&quot;&quot;>#Headings1#
<OPTION VALUE=&quot;&quot;>No Choice
<OPTION VALUE=&quot;H1&quot;> H1
<OPTION VALUE=&quot;H2&quot;> H2
<OPTION VALUE=&quot;H3&quot;> H3
<OPTION VALUE=&quot;H4&quot;> H4
<OPTION VALUE=&quot;H5&quot;> H5
<OPTION VALUE=&quot;H6&quot;> H6
<INPUT TYPE=&quot;submit&quot; VALUE=&quot;process&quot;>
<INPUT TYPE=&quot;reset&quot; VALUE=&quot;Clear&quot;>
</SELECT>

<SELECT NAME =&quot;#Fonts1#&quot;>
<OPTION VALUE=&quot;&quot;>#Fonts1#
<OPTION VALUE=&quot;&quot;>No Choice
<OPTION VALUE=&quot;Arial&quot;> <FONT FACE=&quot;Arial&quot;> Arial </Font>
<OPTION VALUE=&quot;Book Antiqua&quot;> <font face=&quot;Book Antiqua&quot;>Book Antiqua</font>
<OPTION VALUE=&quot;Bookman Old Style&quot;><font face=&quot;Bookman Old Style&quot;>Bookman Old Style</font>
<OPTION VALUE=&quot;Courier&quot;><font Face=&quot;Courier&quot;>Courier </font>
<OPTION VALUE=&quot;Garamond&quot;>Garamond
<OPTION VALUE=&quot;Tahoma&quot;>Tahoma
<OPTION VALUE=&quot;Times New Roman&quot;>Times New Roman
</SELECT>
<SELECT NAME =&quot;#Colours1#&quot;>
<OPTION VALUE=&quot;&quot;>#Colours1#
<OPTION VALUE=&quot;&quot;>No Choice
<OPTION VALUE=&quot;Silver&quot;>Silver
<OPTION VALUE=&quot;Gray&quot;>Gray
<OPTION VALUE=&quot;Maroon&quot;>Maroon
<OPTION VALUE=&quot;Green&quot;>Green
<OPTION VALUE=&quot;Navy&quot;>Navy
<OPTION VALUE=&quot;Purple&quot;>Purple
<OPTION VALUE=&quot;Olive&quot;>Olive
<OPTION VALUE=&quot;Teal&quot;>Teal
<OPTION VALUE=&quot;Red&quot;>Red
<OPTION VALUE=&quot;Lime&quot;>Lime
<OPTION VALUE=&quot;Blue&quot;>Blue
<OPTION VALUE=&quot;Magenta&quot;>Magenta
<OPTION VALUE=&quot;Yellow&quot;>Yellow
<OPTION VALUE=&quot;Cyan&quot;>Cyan
<INPUT TYPE=&quot;submit&quot; VALUE=&quot;process&quot;>
<INPUT TYPE=&quot;reset&quot; VALUE=&quot;Clear&quot;>
<BR>
<BR>
<SELECT NAME =&quot;#HLine1#&quot;>
<OPTION VALUE=&quot;&quot;>#HLine1#
<OPTION VALUE=&quot;&quot;>No Choice
<OPTION VALUE=&quot;HR&quot;>Horizontal Rule
<INPUT TYPE=&quot;submit&quot; VALUE=&quot;process&quot;>
<BR>
<INPUT TYPE=&quot;Text&quot; NAME=&quot;Return1&quot; VALUE=&quot;#Return1#&quot;>
<INPUT TYPE=&quot;submit&quot; VALUE=&quot;process&quot;>
<BR>
<BR>


The hidden form fields on page 2:

<INPUT TYPE=&quot;Hidden&quot; NAME=&quot;Heading&quot; VALUE= &quot;#Heading#&quot;>
<INPUT TYPE=&quot;Hidden&quot; NAME=&quot;Headings1&quot; VALUE= &quot;#Headings1#&quot;>
<INPUT TYPE=&quot;Hidden&quot; NAME=&quot;Fonts1&quot; VALUE= &quot;#Fonts1#&quot;>
<INPUT TYPE=&quot;Hidden&quot; NAME=&quot;Colours1&quot; VALUE= &quot;#Colours1#&quot;>
<INPUT TYPE=&quot;Hidden&quot; NAME=&quot;HLine1&quot; VALUE= &quot;#HLine1#&quot;>

Page 3:
<CFOUTPUT>
<CFIF #Headings1# NEQ &quot;&quot;> <#Headings1#></cfif>
<CFIF #Fonts1# NEQ &quot;&quot;> <Font Face=&quot;#Fonts1#&quot;></cfif>
<CFIF #Colours1# NEQ &quot;&quot;> <Font Color=&quot;#Colours1#&quot;></cfif>
<CFIF #HLine1# NEQ &quot;&quot;> <#Hline1#></cfif>
<!--- <CFSET Return1=#return#> --->
<CFLOOP Condition=&quot;#Return1# GT 0&quot;>
<BR>
<CFSET #Return1#=#Return1# - 1>
</CFLOOP>
#heading#
<CFIF #Headings1# NEQ &quot;&quot;> </#Headings1#></cfif>
<CFIF #Fonts1# NEQ &quot;&quot;> </Font></cfif>
<CFIF #Colours1# NEQ &quot;&quot;> </Font></cfif>
<CFIF #HLine1# NEQ &quot;&quot;> </#Hline1#></cfif>
</CFOUTPUT>
 
Hey Sam,

First, I would recommend not sending the variables from page 1 to page 2 via form variables. I would just re-query on page2 and populate the form from the same query on page 1. In addition to being a little more efficient, it also helps keep page 2 with fresh data in case the database were to change. I may be missing something in how your app needs to work but I think this would make things a little easier.

I didn't see anything wrong with your code on page 2 which would keep the variables from getting sent but you have a lot of code and it's easy to miss something. I would recommend stripping everything else back so you just have a <form ...> tag, one input box, a submit button, and your closing <form>. Then on page 3, check to see if you can use the value from this one input variable. I think it's a lot easier to debug odd problems like this if you strip away everything else. If it works with just the first input, start adding them back until you hit a problem. Chances are, it will be easy to spot. If you find an input that won't get received by page 3 and don't see why, just post the code between the form tags and the code that's receiving the value on page 3 and I'll see if I can spot the problem.

One other thing to be careful about. When you use variables to populate the value attribute of an html tag, remember to escape any quotes as this will mess things up if your variable contains something like 'The title is &quot;My Book&quot;'. What happens is the input becomes <input type=&quot;text&quot; name=&quot;t1&quot; value=&quot;The title is &quot;My Book&quot;&quot;> and this causes the browser to think the value stops at &quot;M&quot; when it reaches the first double quote.

Hope this helps,
GJ
 
To much code, to read, but I would take off the hidden fields and leave them as &quot;text&quot; while testing. Once everything is like the way you want to show it. It is ready to be passed.


Grover Fields
Web Developer/SQL Database Administrator
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top