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

multiple lines in sql field

Status
Not open for further replies.

thegiraffe

Programmer
Mar 8, 2002
49
IE
I am trying to do a noticeboard, but calling it using java!

It works fine, i've got an onclick refresh page with thread id=thread, I have a script at the bottom of the page saying if thread <> empty etc build variable (which consists of a grid getting values from an sql table) and then calling the javascript at the very bottom of the page.

This all works, i was impressed first time!! Anyway things started to go pear shaped when i put the message field in, it works if the field has only one line with no enters, the problem is when you have more than one line with enters, i get the java error Unterminated string constant & sShowThread is undefined.

The code is like

<%
sShowThread = &quot;<table>&quot; ......i'll skip the other stuff
sShowThread = sShowThread & &quot;<tr><td><span class=mainblack>&quot; & objRsS(&quot;message&quot;) & &quot;</span></td></tr>&quot;
sShowThread = sShowThread & &quot;</table>&quot;

response.write &quot;<script LANGUAGE=&quot;&quot;JavaScript&quot;&quot;>sShowThread = &quot;&quot;&quot; & sShowThread & &quot;&quot;&quot;</script>&quot;

%>
<script language=&quot;JavaScript&quot;>
function ShowThread() {
document.getElementById('d1').innerHTML = sShowThread;
}

ShowThread();
</script>

d1 in the showthread function is the div area on the page where i'm putting the data.

This normally works but i must have to do something to the text for it to work, i've quickly tried to put it in an array split by vbcrlf and use it that way, but that doesn't seem to work either, unless its the way i'm doing it.

I need to do it like above because the whole page is set this way, so if someone hovers over a different section it then changes whats in the section.

Any ideas, any help, help, help me please!!! Dave

Theres nothing worse than an idea when its the only one we have!
 
The problem is when the string gets written back to the browser, all carriage returns etc will be put in the string, therefore breaking the string. An easy solution to this would be to insert the string into a div and hide the div ie:

<div style=&quot;display:none&quot; id=TextHolder>
<%=sShowThread%>
</div>

then your script would be

<script language=&quot;JavaScript&quot;>
function ShowThread() {
document.getElementById('d1').innerHTML = document.getElementById('TextHolder').innerHTML ;
}

ShowThread();
</script>
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top