nV News Forums


nV News Forums (http://www.nvnews.net/vbulletin/index.php)
-   Software Development (http://www.nvnews.net/vbulletin/forumdisplay.php?f=53)
-   -   ASP MySQL and TEXTAREA Question (http://www.nvnews.net/vbulletin/showthread.php?t=131686)

technoid 04-18-09 08:23 AM

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?


' 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>


' 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 -->
var txtHTML = document.getElementById("myDIV").innerHTML;
txtHTML = txtHTML.replace(/<BR>/g, "\n");
document.getElementById('story').value = txtHTML;

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)

t3hl33td4rg0n 05-14-09 02:07 AM

Re: ASP MySQL and TEXTAREA Question
What if you did something like this?


var dynStory = new String('');
dynStory = <% response.write(story) %>;
document.getElementById('story').value = dynStory;

All times are GMT -5. The time now is 03:07 PM.

Powered by vBulletin® Version 3.7.1
Copyright ©2000 - 2015, Jelsoft Enterprises Ltd.
Copyright 1998 - 2014, nV News.