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

passing form variable adds to create a list!

Status
Not open for further replies.

leadman

Programmer
Joined
Jun 11, 2001
Messages
177
Location
US
Hi all,
Im sending all my cart variables to a page where folks can make final changes to anything they entered (shipping address, number of products, etc) Most of these variables are passed as hidden form fields to the edit page where they are used to populate input boxes with the same name which can be edited and sent back to the final checkout page again. The problem is that, upon return (after making changes), the variables are not changed but rather added to the previous value in list form. Here is an example.
On the page where the user makes a final check of all the info there is a button called "Edit Info" which sends, among other things, the following hidden variable:

<input type=&quot;hidden&quot; name=&quot;phone&quot; value=&quot;#form.phone#&quot;>

The value has been obtained, obviously, from a form that submitted to it. In this example, the value of #form.phone# is 123-456-7890 and has passed correctly as such to the next template (the one where values can be changed). The value is used to populate the following input box:

<cfinput type=&quot;Text&quot; name=&quot;phone&quot; message=&quot;Please enter billing phone with area code.&quot; validate=&quot;telephone&quot;
required=&quot;Yes&quot;
size=&quot;15&quot;
maxlength=&quot;25&quot;
value=&quot;#form.phone#&quot;>

On this template is a button at the bottom called &quot;Submit Edits&quot; which sends the field back to the first template with the new value (or with the old one if no change was made. NOW - when it gets back the original template, the code that displays this value (#form.phone#)shows the following value:

123-456-7890,123-456-7890

It has two of this same value! This is happening to all the varibles being sent back (address, name, email, etc). And if the user had made a change to a value then the result is the original value, then a comma, then the new value. Why is this simple passing of form variables causing a list to form?

 
I've had this happen to me before. It's clear that you have defined the form variable twice on the page that is submitted (the page before the dual-value appears). You are probably using a single template that calls itself with a variable that tells it with section of code to execute. (For example, I almost always use a variable called &quot;operation&quot; that is a hidden form field. There is a big switch statement in my template that switches on the value of &quot;operation&quot;.) Anyway, if you're doing something similar, check your code carefully to see if you are outputting the hidden field when you also have a text input field. You are probably carrying the hidden field information into the page where the user enters data, or through an error in logic, the code is outputting the hidden field twice. One technique is to insert some &quot;debugging writes&quot; in your code next to every instance of one of the offending form fields. For example,

QQQ1<input type=&quot;hidden&quot; name=&quot;phone&quot; ...>
or
QQQ2<input type=&quot;text&quot; name=&quot;phone&quot; ...>

Then run the script and &quot;View Source&quot; of the offending browser page. Search for &quot;QQQQQ&quot;. Use different debugging writes for each instance in the code so that you can identify which is which when you view Source. This should get you there. If you do this for one of the variables, you'll probably find the problem for the others. If not, add more debugging writes.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top