Link to home
Start Free TrialLog in
Avatar of neverrealm
neverrealm

asked on

String with carriage returns causes problems

I am trying to display a String by default into a text area using a JSP directive and it works unless there is a carriage return contained in the String that is returned.

What I am looking for is what character will represent the carriage return to do a substring and break it up into multiple javascript assignments.

For instance:

Now there is:

document.getElementById('coverRow2').innerHTML = "<textarea cols='40' rows='10' name='coverPageContent' id='coverPageContent' onKeyUp='setScreenState(true); wrap'><%=faxCoverBLOB.getCompressedBlobString() %></textarea>";

I think I would need to go with
javascriptString += substring(faxCoverBLOB.getCompressedBlobString(), 0, indexOf('character')) or something like that, but I don't know which character I should search for.
Avatar of siliconeagle
siliconeagle

you will also have problems with quotes("):-
faxCoverBLOB.getCompressedBlobString().relpace("\n","\\n").relpace("\"","\\"");
actually
faxCoverBLOB.getCompressedBlobString().relpaceAll("\n","\\n").relpaceAll("\"","\\"");
Avatar of neverrealm

ASKER

That's a great idea, but it didn't work.  Also my IDE won't compile the page with the replaceAll("\"", "\\"") portion.  I still get an unterminated string constant with this.
Well, I had to bite the bullet and include the textarea in the main source of the html.  Does anyone have a good way of handling an unchecked checkbox submit?
ASKER CERTIFIED SOLUTION
Avatar of siliconeagle
siliconeagle

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
if you have a boolean value for your checkbox:-
<% boolean chkBoxVal=(request.getParameter("chkBoxParam")!=null)?true:false;%>
Actually, I figured it out already, but gave you the answer.  I have a javascript method that actually does the submitting and I can pass additional request paramaters to it and have used that.

Thanks anyhow.  The replaceAll function may come in handy later.