Improve company productivity with a Business Account.Sign Up

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 346
  • Last Modified:

How to ensure surrounding div class within textarea content?

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
bemara57
Asked:
bemara57
  • 3
1 Solution
 
Brad Dobyns, CSMScrumMasterCommented:
Try this:

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

Thanks,
Brad
0
 
Brad Dobyns, CSMScrumMasterCommented:
Did that not work?
0
 
bemara57Author Commented:
No, I get an error:

Error: mytextarea.setContent is not a function
Source File: file:///C:/Temp/test.htm
Line: 12
0
 
Brad Dobyns, CSMScrumMasterCommented:
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
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

The 14th Annual Expert Award Winners

The results are in! Meet the top members of our 2017 Expert Awards. Congratulations to all who qualified!

  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now