Go Back   nV News Forums > Software Forums > Software Development

Newegg Daily Deals

Reply
 
Thread Tools
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
Old 05-14-09, 02:07 AM   #2
t3hl33td4rg0n
Dethklok Returns!
 
t3hl33td4rg0n's Avatar
 
Join Date: Dec 2004
Location: Kent, OH
Posts: 2,142
Send a message via AIM to t3hl33td4rg0n Send a message via MSN to t3hl33td4rg0n Send a message via Yahoo to t3hl33td4rg0n
Default Re: ASP MySQL and TEXTAREA Question

What if you did something like this?

Code:
<script>
var dynStory = new String('');
dynStory = <% response.write(story) %>;
document.getElementById('story').value = dynStory;
</script>
__________________


Intel QX9650 @ 3.83GHzXFX 780ieVGA GTX 560Ti8GB GSkill DDR800Creative Sound Blaster X-Fi Titanium PCI-ESeagate 1.5TB . 4x Samsung 2TB

Quote:
Originally Posted by MowTin View Post
....it's so clear how government makes things worse not better...
t3hl33td4rg0n is offline   Reply With Quote
Reply


Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump


All times are GMT -5. The time now is 08:38 PM.


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