Hi Fred,
I included (with some modification) your code but the results are very
strange.
The altered function is:
===========================================
function replaceSpecialChar(sourceString) {
var strCurr = sourceString;
var strNew = "";
var strRight = """
for (l=0; l<strCurr.length; l++) {
(strCurr.charAt(l) == '"') ? strNew += strRight : strNew +=
strCurr.charAt(l);
}
return strNew;
}
===========================================
This is being called in a code fragment when from the input box
something is moved over to the combobox, namely a new Option is being
created. The relevant fragment looks like this:
===========================================
var text = srcfield.value;
var value = replaceSpecialChar(srcfield.value);
alert("converted String \n" + "text: " + text + "\tvalue " +
value);
fieldtochange.options[fieldtochange.options.length] = new
Option(text,value);
===========================================
The thing is that the value to be displayed is stored in the text var
and the value to be saved (and not to truncated) value is stored in
value.
Okay, first of all I add my new value from the inputBox to the combox
-> works fine with all it's expected behaviour. I send the form to the
server where the option, exactly it's value is saved in a DB.
Now it comes! When I retrieve the value from the DB for display in the
list both value and and the text are stored/displayed as the the
encrypted version.
Okay, I save the form with this field a second time and refetch it
afterwards again. The result: the text is properly displayed (means
encrypted in html) but the value again isn't. Submitting and
retrieving same form again cuts the whole substring from the beginning
of ' " '.
========================================
1.) after the first save/refetch
<option value="let"s move" selected="selected">let&quot;s
move</option></select>
2.) after second save/refetch
<option value="let"s move" selected="selected">let"s
move</option></select>
3.) after third save/refetch
<option value="let" selected="selected">let</option></select>
========================================
To be honest I don't even know if the reason is the browser or the
server. Finally it really drives my crazy because it seems that there
is no way of moving around strings containing quotes.
Any idea will be appreciated
TIA
Frank
Fred Basset <fr*********@whosyourdaddy.com> wrote in message news:<3f***********************@news.frii.net>...
This appears to work for me ... pass in the field object (i.e. the text
box) and it will return a string with the quote marks replaced as you
wish.
function correct( oField )
{
var strCurr = oField.value;
var strNew = "";
var regWrong = /\"/;
var strRight = """
for (i=0; i<strCurr.length; i++)
strNew += strCurr.charAt(i).replace(regWrong,strRepl);
return strNew;
}
I'm only a beginner when it comes to proper Regexp usage, so there may
be a more efficient way of doing the same that I'm unaware of.
Fred Basset
fr*********@whosyourdaddy.com
*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!