473,657 Members | 2,592 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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

1 New Member
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 3224
azrar
11 New Member
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 Recognized Expert Specialist
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 New Member
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
11037
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 SFSB and, from there, to the database. On the front end, all cells appear as text fields. However, for certain cells, when the user clicks on the cell, the text field turns into a drop-down field (i.e. Select object), defaulting to the value...
3
1657
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 is below: Label1.Text = "8 " & UCase(strOpen) 'strOpen = "Open"
1
2209
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 from a db which creates hidden fields populated by prices once the onchange handler fires it sets the text for the text field price and the hidden field Tsize, but I can't get it to set the txt of oldprice from the hidden field prevprice.
3
2198
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 hidden field respectfully and the value from dynamically created hidden fiields in to a text fieldin to a text field all at the same time Here's the code as viewed through the browser <body bgcolor="#FFFFFF" text="#000000" > <SCRIPT...
11
5889
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
3309
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 does various other actions. Is it possible to display the text box just for the current record, rather than it displaying for all following records at the same time, i.e. set visibility to true where record id - xxx
7
29130
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 below the comment with a spell check & submit button. Clicking "Amend" would display the same buttons & text field but pre-populated with the original comment. Using Java Script how do I show / hide the text field in my list of comments but have...
2
1296
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 saved data with following values roll = 1 & date = 15/12/2006 now, I want to write code which avoid duplicate entry i.e user could’nt save record with same values ie roll = 1 & date = 15/12/2006.
3
4496
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 the JOIN between Number field and Text field and for that I should have a query to do the Text to Integer conversion before I try the JOIN Query. I would like to know if the following is possible I want to do 2 things in the same Query, ...
5
9708
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 myview, in f varchar(50)) returns varchar(100) as Now i want to pass row and name of field and let it return the value from function on basis of field name i pass to the function like
0
8425
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8845
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8743
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8522
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
7355
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6177
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5647
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
1
2745
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
1736
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.