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

Single quote in text box 2

Status
Not open for further replies.

petermeachem

Programmer
Joined
Aug 26, 2000
Messages
2,270
Location
GB
I can't work out how to handle quotes in mylastname here. This must be easy, but I just can't fix it.

Response.Write " <td width='257' height='30'><input type='text' name='txtLastName' size='20' maxlength='20' value = '" & mylastname & "'></td>
 
Replace it with 2 of them

____________ signature below ______________
The worst mistake you'll ever make is to do something simply the way you know how while ignoring the way it should be done
 
Doesn't work. If mylastname contains m'eachem I just get m in the textbox with the code above. If I do this
mylastname = replace(mylastname,"'","''")
before the response.write, I get exactly the same.

That is the first thing I tried.
 
Do this instead...

Code:
Response.Write "<td width='257' height='30'><input type='text' name='txtLastName' size='20' maxlength='20' value = [!]""[/!]" & mylastname & "[!]""[/!]></td>"

And don't double the apostrophes.

-George

Strong and bitter words indicate a weak cause. - Fortune cookie wisdom
 
>mylastname = replace(mylastname,"'","''")
[tt]mylastname = replace(mylastname,"'","&#x27;")[/tt]
 
no need to use replace function...try this:

Code:
Response.Write "      <td width='257' height='30'><input type='text' name='txtLastName' size='20' maxlength='20' value = [red]""" & mylastname & """[/red]></td>"

-DNG
 
hmm...very slow today...George beat me to it...

-DNG
 
Great, thanks to all. Just have to stop people entering " in a name!
 
that shouldnt be a problem...
you can use server.htmlencode() function

-DNG
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top