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

Textbox won't display all text if an ' is in the text

Status
Not open for further replies.

dommett

Programmer
Apr 30, 2004
33
US
I have a form (using Frontpage 2002) with an input textbox.
<input type="text" name="CompanyName" size="60" value = '<%Response.Write(rsCoupon("Company Name"))%>'>

But if rsCoupon("Company Name") includes an apostrophy (sp?), it only shows the text up to it. So "Amy's Antiques" just becomes "Amy".

Any idea why this happens or what to do to fix it?
Thanks,
Amy
 
Unfortunately - that didn't seem to change anything.
 
And this ?
Response.Write(Replace(rsCoupon("Company Name"), "'", "%27))

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244
 
Hi Amy,

just use the unescape function to display in the textbox:
Code:
response.write unescape(rsCoupon("Company Name"))

Before updating db data, use server.htmlencode function
Code:
coupon=server.htmlencode(request.form("CompanyName"))

Cheers,
Andy

[blue]The last voice we will hear before the world explodes will be that of an expert saying:
"This is technically impossible!" - Sir Peter Ustinov[/blue]
HP:
 
I'm not having much luck here with this.

PHV - I tried the replace function and I'm not sure what "%27 is supposed to be but it causes an error. So I tried things like CHR(39) and it still didn't work. I can use any other letter like "x" and I see the x in the middle of my name where an apostrophe is supposed to be but that obviously doesn't look right.

Andy - I tried the unescape with and without using the server.htmlencode when I reassign the form field back to the recordset but it didn't seem to change anything.

Any other ideas I should try? Anyone?
Amy
 
Sorry for the typo:
Response.Write(Replace(rsCoupon("Company Name"), "'", "%27"))

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244
 
I tried that too and got:
"Amy's" came out "Amy%27s"

 
Hello dommett,

Then it is the combination of advice you've got.
[tt] Response.Write(unescape(Replace(rsCoupon("Company Name"), "'", "%27"))) [/tt]

regards - tsuji
 
Better use URLencode then: (equal to replacing ' with %27)
Code:
coupon=server.[b]url[/b]encode(request.form("CompanyName"))
response.write unescape(rsCoupon("Company Name"))

Cheers,
Andy

[blue]The last voice we will hear before the world explodes will be that of an expert saying:
"This is technically impossible!" - Sir Peter Ustinov[/blue]
HP:
 
Andy (and others!),
Thanks for the help. I now can see the full text string with apostrophys in the name but using the server.urlencode causes a "+" wherever there is supposed to be a space. (By the way, without the server.urlencode, I only see the text up to the first space.) Do I just have to do a replace as well for them??? This just seems like a lot of work to get apostrophys to be ignored within the html.

Thanks,
Amy
 
OK - I feel a little silly. The real problem was I was using value='<%Response.Write....' and I should have been using value="<%Response.Write....". Double quotes instead of single quotes! Thanks everyone for the help!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top