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

Quotes in data fields?? How to handle?

Status
Not open for further replies.

BPetro

Programmer
Oct 1, 2002
59
US
I have the following statement:
<INPUT TYPE=&quot;text&quot; NAME=&quot;FormFieldName&quot;
VALUE=&quot;<% response.write RSItem(&quot;FieldName&quot;) %>&quot;
SIZE=10 MAXLENGTH=10 >

The problem is that the field from the database contains quotes so the VALUE = &quot;aValue&quot; is getting messed up because the quotes in the field are acting to short-circuit the percieved end of value field.

SO - is there a way to use alternatives to &quot; to surround values? I'm imagining something like the following pseudo-code, but I'm not sure if its legal - any ideas?

if containsQuotes(RSItem(&quot;FieldName&quot;)) then
VALUE=[<% response.write RSItem(&quot;FieldName&quot;) %>]
else
VALUE=&quot;<% response.write RSItem(&quot;FieldName&quot;) %>&quot;
end if
 

Use server.HTMLencode(RSItem(&quot;FieldName&quot;))

Thanks,

Gabe
 
I'm not sure that helps?? I know that handles things like -- &lt;Table&gt -- and so forth but does it encode the &quot; signs? Those are what are causing the problem...

If so, is this the syntax you are suggesting:
<INPUT TYPE=&quot;text&quot; NAME=&quot;FormFieldName&quot;
VALUE=&quot;<% &quot;server.HTMLencode(RSItem(&quot;FieldName&quot;)) %>&quot;
SIZE=50 MAXLENGTH=100 >

In order for this to work its gonna have to alter the &quot; marks as well as all the brackets, etc... I didn't think it did that -- but I'll try it for sure!
 
Oops I messed up my own quotes above - I meant:
VALUE=&quot;<% server.HTMLencode(RSItem(&quot;FieldName&quot;)) %>&quot;
 
Nope - I tried the following and I'm not getting any text put into the form field at all... Any more ideas or can someone tell me what I might be misinterpreting about the first suggestion?

<INPUT TYPE=&quot;text&quot; NAME=&quot;BoldText&quot;
VALUE=&quot;<% server.HTMLencode(RSItem(&quot;BoldText&quot;)) %>&quot;
SIZE=55 MAXLENGTH=150 >
 
Code:
<%
dim sVar

sVar = &quot;Gabe's &quot;&quot;Good code&quot;&quot;&quot;

%>
<INPUT TYPE=&quot;text&quot; NAME=&quot;BoldText&quot; VALUE=&quot;<%=server.HTMLencode(sVar)%>&quot; SIZE=55 MAXLENGTH=150>


The reason it didn't work is you forgot the = before server.
<INPUT TYPE=&quot;text&quot; NAME=&quot;BoldText&quot;
VALUE=&quot;<% =server.HTMLencode(RSItem(&quot;BoldText&quot;)) %>&quot;
SIZE=55 MAXLENGTH=150 >


Thanks,

Gabe
 
GabeC you are a gentleman and a scholar - it works, sorry for the density!
 
Another suggestion...

<INPUT TYPE=&quot;text&quot; NAME=&quot;FormFieldName&quot;
VALUE=&quot;<% response.write REPLACE(RSItem(&quot;FieldName&quot;),&quot;&quot;&quot;,&quot;'&quot;) %>&quot;
SIZE=10 MAXLENGTH=10 > -- Just trying to help...
[wolf]<--- This is a wolf? We need a new icon.......
mikewolf@tst-us.com
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top