473,387 Members | 1,698 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

How to display the entire field value in the text box, where the field has spaces?

I am developing a simple web site in ASP. I have a web page which has a form, and I want to set the values of two text box to 2 fields selected by a query. One of the fields is a name field which has the First Name and the Last Name separated by a space. The text box only shows the First Name and not the last Name. Any idea how to show the complete field value?
Expand|Select|Wrap|Line Numbers
  1. <%
  2. Response.Expires = 0
  3. Response.Cookies ("name")= ""
  4. Response.Cookies ("Eid")= ""
  5. Dim a,b,c,e,f,con,strQx,rs,strUrl,connectionString,nm,eid
  6.  
  7. a = Request.Form("t1")
  8. b = Request.Form("t2")
  9. connectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=D:\My Documents\My Team\TM Testing\Team Details4.mdb;"
  10.  
  11. Set con = Server.CreateObject("ADODB.Connection")
  12. con.Open connectionString
  13. Set rs = Server.CreateObject("ADODB.Recordset")
  14. strQx = "SELECT Users.NAME, Users.[EMP ID] FROM Users WHERE UserID='"&a&"' AND Password='"&b&"' " 
  15. rs.Open strQx,con, adOpenForwardOnly, adLockOptimistic
  16.  
  17.  
  18. If rs.EOF Then
  19.     rs.close
  20.     Set rs = Nothing
  21.     con.close
  22.     Set con = Nothing
  23.     strUrl = "http://localhost/index.htm"
  24.     strUrl = strUrl & "?Error"    
  25.     Response.Redirect strUrl
  26. End If    
  27.  
  28. c = rs("Name")
  29. e = rs("EMP ID")
  30.  
  31. %>
  32. <html>
  33.  
  34. <head>
  35. <title>Online Tracker System</title>
  36. </head>
  37.  
  38. <body onload=setfoc()>
  39.  
  40. <h1><font face="Calibri" size="6" color="#99FFCC"><b><img border="0" src="image3061.gif" width="377" height="114">Online
  41. Tracker System&nbsp;&nbsp;&nbsp;&nbsp; </b></font><img border="0" src="image315.gif"></h1>
  42.  
  43. <form method="POST" name="f1" action="upload.asp">
  44.     <p align="left"><font face="Arial Rounded MT Bold"><font size="2">Week:</font> <select size="1" name="D1" tabindex="1">
  45.     <option>WK1</option>
  46.     <option>WK2</option>
  47.     <option>WK3</option>
  48.     <option>WK4</option>
  49.     <option>WK5</option>
  50.   </select>&nbsp;&nbsp;&nbsp; <font size="2">Date :</font> <input type="text" name="T1" size="17" onclick="OpenWin()" readonly tabindex="2">
  51.   <font size="2">Name:</font> <input type="text" name="T2" value=<%=rs("Name")%> size="37" readonly style="position: relative">
  52. </form>
  53.  
  54.  
  55. <script language ="JavaScript">
  56. <!--
  57. function setfoc()
  58. {
  59.     document.f1.D1.focus();
  60. }
  61. -->
  62. </script>
  63. </body>
  64. </html>
  65.  
Aug 14 '10 #1
3 3205
azrar
11
The problem is that you did not put quotation marks around the value attribute of the input.

Expand|Select|Wrap|Line Numbers
  1. <input type="text" name="T2" value="<%=rs("Name")%>" size="37" readonly style="position: relative">
  2.  
Suggestion: use the local variable you created "c" instead of the recordset object.

Expand|Select|Wrap|Line Numbers
  1. <input type="text" name="T2" value="<%=c%>" size="37" readonly style="position: relative">
  2.  
Aug 17 '10 #2
jhardman
3,406 Expert 2GB
Azrar is right, but I think it is valid to use the recordset object there as he does in his first example. Think about this: the recordset object is already there, why bother having IIS create another variable to hold another value you already have a handle on?

In the future, a lot of these types of mistakes become really obvious when you look at the HTML code, this would have appeared like this in the HTML:
Expand|Select|Wrap|Line Numbers
  1. <input type="text" name="T2" value=Indrajit Chakraborty size="37" readonly style="position: relative">
Looking at it this way, it is pretty obvious what Azrar is saying.

Jared
Aug 25 '10 #3
azrar
11
Thanks for your reply Jared.

There are several reasons I suggested using a local variable instead of the recordset object:

1. he had already created local variable "c" in his code ( c = rs("Name") )

2. local variables are much lighter than recordset objects (less overhead). Accessing the value of a local variable is much faster than accessing the data in an object. If you need to access that data more than once in the script, it starts making a difference.
Aug 25 '10 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: ehm | last post by:
I am working on creating an editable grid (for use in adding, deleting, and editing rows back to an Oracle database). I have a JSP that posts back to a servlet, which in turns posts to a WebLogic...
3
by: d2bishop | last post by:
Hi, I am programmatically setting the .Text property of a number of Labels on my Windows form at runtime, but I am experiencing some very strange behaviour when I do this. The code I am using...
1
by: Roy Adams | last post by:
Hi Group I'm trying to write from dynamically created hidden fields to a txt field in the onchange event handler within a select. basically the number for the for loop is generated by a field...
3
by: Roy Adams | last post by:
Hi I'm reposting this question because for some reason can't post follow up question to this thread. What I'm trying to do is put the value and text from a a select in to a text field and to a...
11
by: Dixie | last post by:
How can I programatically, take some Date/Time fields present in a table in the current database and change their type to text? dixie
1
by: David | last post by:
Hi, I have a continuous form. For each record I have a field 'HeldDate' (Text Field from a table) Against each record I have a button which sets the visibility of this text box to 'True' and...
7
by: FP | last post by:
I'm new to Java Script. I'm displaying comments people have made. Below each persons' comment I want to add 2 buttons "Reply" and "Amend". Clicking "Reply" would display an empty text field...
2
by: umeshkakade | last post by:
I have used mdb with 4 fields - rollno, name, date & attendance. I have design a form for data entry by considering above fields. I have connected it to DAO database object. Suppose I have...
3
by: AccessHunter | last post by:
Please help.... I am trying to JOIN two tables, Table1 and Table2, the fields used for the JOIN are Table1.CaseNum (Number field) and Table2.Casetxt (Text field). I know it will not let me do...
5
by: parry2k | last post by:
I have one view with 3 fields like the view name is myview and it has following sql statement. select fn,ln,city from tablea I created a function like below:- create function myfun(in t...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.