html textbox

liunx

Guest
I am using MS SQL server 2000 for my database. I am trying to display a text field value from a table in my database in a HTML textbox. The display is truncated as soon as a blank space is encountered. How can this be corrected?<br />
<br />
Eg. I want to display 'Prathima B S' in a text box<br />
Only 'Prathima' is diplayed. The initials are truncated.<br />
<br />
Note: this happens only when i try to display a text value fetched from a table. If i give a constant, there is no problem<!--content-->what do you have the database table set at? text or varchar or whatever? also make sure you box is big enough to commadate those letters.<!--content-->I am using MS SQL server 2000 for my database. I am trying to display a text field value from a table in my database in a HTML textbox. The display is truncated as soon as a blank space is encountered. How can this be corrected? <br />
<br />
Eg. I want to display 'Prathima B S' in a text box <br />
Only 'Prathima' is diplayed. The initials are truncated. <br />
<br />
Note: this happens only when i try to display a text value fetched from a table. If i give a constant, there is no problem<br />
<br />
<br />
23/01/2002<br />
<br />
Yes the textbox is huge and can accomadate the string.<br />
In my table, one field is a varchar and the other is a char.<br />
I am getting the same results(as stated above) while trying to display either of them in a html textbox!!!!<br />
<br />
__________________<br />
prat<!--content-->I use SQL Server, with the nvarchar cell setting and am able to get entire sets of data with tons of spaces. We may need to see your code for the insert.<!--content-->also make sure when you set the value of the textbox it is INSIDE quote: <input type=text name=whatever value="$form.value#"><br />
<br />
if not, it will only assign up the first space.<!--content-->I have printed below the code i am using to display text in a textbox. Here the table field addr is of type nvarchar(as u had suggested previously) and name is of type varchar. Both the fields are being truncated at the first space encountered when displayed in the html textbox!!!!<br />
<br />
The size (set to 100) is enough and more as i am filling only 25 characters.<br />
<br />
set conn = Server.CreateObject("ADODB.connection")<br />
set rs=server.CreateObject("ADODB.recordset")<br />
conn.open "HELPDESK","sa","sa"<br />
sql="select * from prat1"<br />
set rs=conn.Execute(sql)<br />
rs.MoveFirst()<br />
while not rs.EOF <br />
cname = rs("cname")<br />
caddr = rs("addr")<br />
rs.MoveNext()<br />
wend<br />
%><br />
<INPUT type="text" id=text1 name=text1 value = <%=cname%>> <br />
<BR><br />
<INPUT type="text" id=text2 name=text2 value = <%=caddr%> size=100><!--content-->Prathima,<br />
<br />
I had already suggested that you put your value in quotes, else it will only assign up to the first space... but I see your code without quotes in the value:<br />
<br />
<INPUT type="text" id=text1 name=text1 value = <%=cname%>> <br />
<BR> <br />
<INPUT type="text" id=text2 name=text2 value = <%=caddr%> size=100><br />
<br />
if you view the source you should see that all the data made it into the form tag, but the HTML recognizes only the entry to the first space.<br />
<br />
<br />
change it to:<br />
<br />
<INPUT type="text" id=text1 name=text1 value = "<%=cname%>"> <br />
<BR> <br />
<INPUT type="text" id=text2 name=text2 value = "<%=caddr%>" size=100><br />
<br />
and all should be well. <br />
<br />
The reason for this is that HTML responds well to things outside of quotes as long as there are no spaces or special characters. This is really a HTML problem.<!--content-->and for your viewing pleasure, look at the following simplified code.... and view the page that is renered. Notice that without quotes, the HTML will only assign the value up to the space.<br />
<br />
<br />
<html><br />
<head><br />
<title>pop-up</title><br />
</head><br />
<body><br />
<form><br />
<INPUT type="text" id=text1 name=text1 value =myValue> <br />
<BR> <br />
<INPUT type="text" id=text2 name=text2 value =my value> <br />
<BR> <br />
<INPUT type="text" id=text2 name=text2 value ="my value"> <br />
</form><br />
</body><br />
</html><!--content-->
 
Back
Top