Solved

How to ensure surrounding div class within textarea content?

Posted on 2008-06-24
5
339 Views
Last Modified: 2008-07-09
I'm using a textarea for the ability of end-users to change content on the server. I load up the text file from the server to the textarea, then save everything from the textarea to the server when the save button is clicked. The thing is that I need the textarea content to ALWAYS be surrounded by <div class="userContentArea">...</div>. I don't want to cast/uncast the div tag to the content everytime I get or save the content because I have other areas of my page reading the textarea via AJAX on the fly and need those surrounding tags within the textarea content. Also sometimes the user will put the surrounding tag manually, which would end up in duplicated surrounding tags. Is there a way to make <div class="userContentArea">...</div> surround the textarea content at all times, even if the user erases everything off the textarea? I'm trying to get it so the div tag is static and cannot be erased from the textarea content and the only editable area is within <div class="userContentArea">...</div>. Any ideas on how to achieve this?
0
Comment
Question by:bemara57
  • 3
5 Comments
 
LVL 7

Expert Comment

by:Brad Dobyns, CSM
ID: 21860439
Try this:

var mytextarea= document.getElementById("mytextarea");
mytextarea.setContent("<div class="userContentArea">...</div>");

Thanks,
Brad
0
 
LVL 7

Expert Comment

by:Brad Dobyns, CSM
ID: 21870221
Did that not work?
0
 

Author Comment

by:bemara57
ID: 21943008
No, I get an error:

Error: mytextarea.setContent is not a function
Source File: file:///C:/Temp/test.htm
Line: 12
0
 
LVL 7

Accepted Solution

by:
Brad Dobyns, CSM earned 500 total points
ID: 21960021
Considering it took over a week for the asker to respond to the question as to whether or not my suggestion worked...you bet I am going to object to the action. Since I saw that he finally responded, I was going to suggest another possibility. If I have the opportunity to do so, I would like to do that.

Thanks,
Brad
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
JS Event Does not Trigger From File 2 38
Can't get page to reload 9 18
How to escape unsafe HTML tags 4 36
How Close unsubmited attempts 10 42
In this article, we'll look how to sort an Array in JavaScript, including the more advanced techniques of sorting a collection of records either ascending or descending on two or more fields. Basic Sorting of Arrays First, let's look at the …
In my daily work (mainly using ASP.net), I need to write a lot of JavaScript code. One of the most repetitive tasks I do are the jQuery Ajax calls. You know: (CODE) I don't know if for you it's the same, but for me is soooo tedious to write the …
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

680 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question