View Single Post
Old 04-18-09, 08:23 AM   #1
technoid
Registered User
 
Join Date: Jul 2004
Location: Denton, Texas
Posts: 505
Default ASP MySQL and TEXTAREA Question

I'm working on a webpage that uses MySQL to store a users information and then a personal story. I have the input and display working but I got the idea of taking the data out once it's in the database and allowing the user to edit it and then put it back in the database. A full profile editor so to speak. I can get the individual elements out, like the name, location, date of bitrth and so on but when I get the story from a MySQL longtext field and try to put it in a TEXTAREA control it won't show up. I've played around with it quite a bit and I can get it to go in the TEXTAREA by putting it in a DIV first and then taking it out of the DIV and putting it in the TEXTAREA but of course I don't want to do that. I'll put code snippets below so you can see what I'm doing. I'm using ASP Classic to create the webpage. Does anyone know what I'm doing wrong?

WHAT DOES NOT WORK

' get story from database
story = oRS("story")

<!-- put story in textarea control -->
<script>document.getElementById('story').value = '<% response.write(story) %>';</script>

<!-- NOTE - This does work -->
<script>document.getElementById('story').value = 'THIS DOES WORK';</script>

WHAT DOES WORK

' get story from database
story = oRS("story")
story = Replace(story, vbcrlf, "<br>")


<!-- put story in div -->
<div id="myDIV" style="visibility:block; display:visible; padding:20px;"><% response.write(story) %></div>

<!-- get story from DIV and put in textarea control -->
<script>
var txtHTML = document.getElementById("myDIV").innerHTML;
txtHTML = txtHTML.replace(/<BR>/g, "\n");
document.getElementById('story').value = txtHTML;
</script>

I can use another method to put the story in the TEXTAREA control and it doesn't work either.

<script>document.register.story.value = '<% response.write(story) %>';</script>

It seems there's something about the story string that the textarea control doesn't like. I've tried changing it several ways but it doesn't want to work without putting in in the DIV first. I can use a hidden DIV to force it to work but I don't want to do that. So any help would be greatly appreciated.

NOTE: If the story is a single paragraph it works okay, but if the story contains more than one paragraph with returns in between them it stops working. That is placing the story directly in the TEXTAREA control instead of the DIV first and then the TEXTAREA. So there's a problem with the returns between the paragraphs.

But trying to simulate what seems to be happening when I put the story in a div and take it out and put it in the textarea doesn't work either.

story = oRS("story")
story = Replace(story, vbcrlf, "<br>")
story = Replace(story, "<br>", vblf)
__________________
Antec-SOLO | ASUS-P5Q-SE | C2D-E8600 | AC-Freezer-7-Pro | Seasonic-S12-550W | 3GB-KVR-PC2-6400 | GTX-560Ti | SB-XtremeGamer | Pioneer-BDR-205 | Samsung-S223B | Dell-U2412M
technoid is offline   Reply With Quote