Forum Moderators: open

Message Too Old, No Replies

Apostrophe Problem

         

aax123

1:37 pm on Sep 23, 2005 (gmt 0)

10+ Year Member



What is wrong with the code below? I am trying to replace an apostrophe ' with double apostrophes in the value and it takes off the ' apostrophe but doesn't add ''

i.e. "Won't Last" now reads "Wont Last"
--------------------------

if (eval("document.forms[0].elements['linerTextAndDescriptionAdj_" + vid + "'].value")!= "") {
eval("divPreview" + vid + ".innerText = '" + eval("document.forms[0].elements['linerTextAndDescriptionAdj_" + vid + "'].value.replace(/'/g,'')") + "'");
}

httpwebwitch

5:39 pm on Sep 23, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



you are replacing ' with ''
'' is an empty string.

you probably want '\'\''
or "''"

try it anyways, see if it works