Solved

HTML and ASP Forms - problems with spaces

Posted on 2004-04-01
5
182 Views
Last Modified: 2010-04-06
Hi,

I am putting together a set of pages that collect data from a form (page 1), confirm the data (page 2) and give confirmation of submission (page 3).

I am having trouble if there is a space between the data entered (eg. "Not Issued" only gets saved as "Not"). It works fine if I don't confirm the data ie. submit it straight to the database. Where is my code going wrong?

Example of code on page 1:

<TABLE bgColor=white border=0 cellPadding=2 cellSpacing=1 width="400" height="70">
  <TR>
    <TD width="500" height="20"><font face="Arial Narrow">Location:</font></TD>
    <TD><font face="Arial"><input type = "text" input name="location" size="30"></TD>
  </TR>
</TABLE>

Page 2:
<HEAD>
      LOCATION = request.form("location")
</HEAD>
<BODY>
  <tr>
    <td width="50%" style="border-style: none; border-width: medium">
    <font face="Arial Narrow">Location:</font></td>
    <td width="50%" style="border-style: none; border-width: medium"><font face="Arial Narrow"><%=location%></font><input type="hidden" name=location value=<%=location%>>&nbsp;</td>
  </tr>

This works fine even if the location has more than one word

Page 3:
<HEAD>      
<%
LOCATION = request.form("LOCATION")
SQL = "INSERT INTO TABLENAME (Location) VALUES ('"&location&"')"
DbObj.Execute(SQL)
%>
</HEAD>
<BODY>
<font face="Arial Narrow">The parking space location <%=location%><input type="hidden" name=location value=<%=location%>>&nbsp;</td> has been added.</font></p>
</BODY>

This part does not work properly if there is more than one word. Only the first word shows up on this page.

Can anyone help please?
0
Comment
Question by:Shellyness
  • 2
  • 2
5 Comments
 
LVL 30

Accepted Solution

by:
third earned 50 total points
Comment Utility
this is common mistake for not using "" in values. just modify this on your 2nd page

<input type="hidden" name="location" value="<%=location%>">&nbsp;</td>

do it also on your third page,

<font face="Arial Narrow">The parking space location <%=location%><input type="hidden" name=location value="<%=location%>">&nbsp;</td> has been added.</font></p>

make it a habit. put quotation marks between the values of tag attributes.
0
 
LVL 12

Expert Comment

by:venkateshwarr
Comment Utility

in pages 2 and 3

Include quotes around the value...

<input type="hidden" name=location value="<%=location%>">
0
 
LVL 1

Author Comment

by:Shellyness
Comment Utility
Thanks heaps guys! I'm very new to this and I have generally no idea!

Sorry venkateshwarr, third pipped you to the post on this one!

0
 
LVL 30

Expert Comment

by:third
Comment Utility

;-)
0
 
LVL 12

Expert Comment

by:venkateshwarr
Comment Utility
That ok...
:-)
0

Featured Post

How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

Join & Write a Comment

When you work with shopping cart / ecommerce relates web sites, you need to pass the certain form post details to the payment gateway process page with required details for the products items you give to order. Also you may need to track the ordered…
I found this questions asking how to do this in many different forums, so I will describe here how to implement a solution using PHP and AJAX. The logical flow for the problem should be: Write an event handler for the first drop down box to get …
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

771 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

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now