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

Truncated variables in a form

Status
Not open for further replies.

MartinDurant

Programmer
Jan 25, 2002
41
GB
I am taking name and address fields from a form in 'ASP Page1.asp' and passing them to 'ASP Page2.asp' for validation. In the case of invalid data the values are put into a hidden table and passsed back to 'ASP Page1.asp' to be redislayed. When the values are redisplayed, they are trunacted at the first space.

I have used
Code:
method="post"
in both forms. I have also a
Code:
reponse.write
statement right infront of the form in 'ASP Page1.asp' to track the value of my variable. It's value is correct everywhere I can check it. When the form displays it, it is truncated.

I just don't don't understand it. Any help gratefuly appreciated.

Thanks.
 
Can't you give a link to the page, or give us some code to see? -Ovatvvon :-Q
 
Below are cut down versions of my two asp pages. Sorry, it's a bit lengthy.

ASP Page1.asp
Code:
<%@ Language=VBScript %>
<%

name=trim(request.form(&quot;name&quot;))
email=trim(request.form(&quot;email&quot;))

Response.Write (&quot;#2&quot; & name & &quot;##&quot;)
%>
<HTML>
<HEAD>
<TITLE>PhotoArtOnline - Order a Commission</title>
<meta name=&quot;description&quot; content=&quot;Turn a favourite photo...&quot;>
<meta name=&quot;keywords&quot; content=&quot;art, photo, drawing, pencil&quot;>
</HEAD>
<BODY>
<img alt=&quot;PhotoArtOnline logo&quot; src=&quot;images/photoartonlinesmall.jpg&quot; HEIGHT=107 WIDTH=167>
<FONT FACE=arial size=&quot;2&quot;>
<h1 ALIGN=&quot;center&quot;><font color=&quot;#006666&quot;>Order a Commission</font></h1>
<P><STRONG> 
To order your commission, click the Checkout button.
</STRONG></P>
You will be redirected to a secure payment facility... 
<%Response.Write (&quot;#3&quot; & name2 & &quot;##&quot;)%>
<FORM id=&quot;form1&quot; name=&quot;getorderid&quot; method=&quot;post&quot; action=&quot;ASP Page2.asp&quot; ><!--enctype=&quot;multipart/form-data&quot;-->
<TABLE>
<TR>
<td><font face=&quot;arial, helvetica&quot; size=&quot;-1&quot;><b>Full name:</b></font></td>
<TD><INPUT NAME=&quot;name&quot; value=<%=name%>></INPUT></TD>
</TR>
<TR>
<TD><font face=&quot;arial, helvetica&quot; size=&quot;-1&quot;><b>Email:</b></font></TD>
<TD><INPUT NAME=&quot;email&quot; value=<%=email%>></INPUT></TD>
</TR>
</TABLE>
<P><INPUT TYPE=&quot;submit&quot; VALUE=&quot;Checkout&quot; id=&quot;checkout&quot; name=&quot;checkout&quot;></P>
</FORM></FONT>

</BODY>
</HTML>

...and ASP Page2.asp
Code:
<%@ Language=VBScript %>
<!-- #INCLUDE FILE=&quot;functions.asp&quot; -->
<%
sub errorform(theerror)
%>
	<html>
	<head>
	<meta name=&quot;generator&quot; content=&quot;microsoft visual studio 6.0&quot;>
	<title>error</title>
	</head>
	<body>
	<img alt=&quot;PhotoArtOnline logo&quot; src=&quot;images/photoartonlinesmall.jpg&quot; HEIGHT=107 WIDTH=167>
	<FONT FACE=&quot;ARIAL&quot; size=&quot;2&quot;>
<H1 ALIGN=&quot;CENTER&quot;><STRONG><FONT color=&quot;#006666&quot;>Order a Commission</FONT></STRONG></H1>

	<%=theerror %>
	<form method=&quot;post&quot; action=&quot;ASP Page1.asp&quot; id=form1 name=form1>
	<%for each item in request.form%>
		<input name=&quot;<%=item%>&quot; type=&quot;hidden&quot; value=&quot;<%=server.htmlencode(request.form(item))%>&quot;>
	<%next%>
	<p><input type=&quot;submit&quot; value=&quot;Return to 'Order a Commission'&quot; id=submit1 name=submit1>
	</form>
	</body>
	</html>
<%
response.end
end sub
'retrieve form fields
name=trim(request.form(&quot;name&quot;))
email=trim(request.form(&quot;email&quot;))
Response.Write (&quot;#1&quot; & name & &quot;##&quot;)
' check for values
if name=&quot;&quot; then
	errorform &quot;You have not entered your name.&quot;
end if
if invalidemail(email) then
	errorform &quot;You have not entered a valid email address.&quot;
end if
%>
<HTML>
<HEAD>
<TITLE>PhotoArtOnline - Payment</title>
<meta name=&quot;description&quot; content=&quot;Turn a favourite photo...&quot;>
<meta name=&quot;keywords&quot; content=&quot;art, photo, drawing, pencil&quot;>
</HEAD>
<body>
Do other stuff
</body>

I run Asp Page1.asp and enter
Code:
Bob the Builder
in the name field and leave the email field blank. Click on the Checkout button. We then jump to Asp Page2.asp. I display the value of
Code:
name
and it is correct. The page tells me that I have not entered a valid email address. I then click on the
Code:
Return to...
button and jump back to Asp Page1.asp. Again I display the value of
Code:
name
and it is still correct. However, when displayed in the form immediatly benath, the value is truncated at the first space.

Thanks for any help.
Martin.
 
You need to put appostrophe's (') or quotes (&quot;) around the value field input on the text box within the page1.asp...should read like this:

<TD><INPUT NAME=&quot;name&quot; value=&quot;<%=name%>&quot;></TD>

You also do not need to put a ending input tag like </input>...but that doesn't have anything to do with your problem...just thought I'd add that in there.

Don't forget to put the quotes around your email value field too like so:

<TD><INPUT NAME=&quot;email&quot; value=&quot;<%=email%>&quot;></INPUT></TD>


When you don't put in quotes, it only takes a value of a word or a number...whenever it encounters a space, the computer figures that the input has stopped, therefore, if you put quotes around it, it can get the full value.

If you go to: you can test it there and you'll see it work...I added in quotes and took out the </input> tag.

Hope this helps.
-Ovatvvon :-Q
 
Thanks very much. You have saved my remaining hair from being pulled out in frustration. I've been staring at this screen so long I've gone quote-blind.

Sometimes it's nice that HTML is so lenient towards poor coding. Other times it's a pain in the 'ass'. From what I've been reading of XHTML 1.0, &quot;if it ain't right, it don't get rendered&quot;. Sound good to me.

Thanks again.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top