Solved

Adding items to text area

Posted on 2009-07-05
3
401 Views
Last Modified: 2012-05-07
Hello all. I have a form which contains an empty textarea, a textbox with add and delete button. If a user types in textbox and click add i want the value to be appended in the textarea. If the user tries to add again in the textbox i want it to be appended to a new line of the textarea. Same thing goes for the delete. The user have to select that number from the textarea and click on delete, that number should be deleted from the textarea.
Can anyone provide me some info or some links ?
0
Comment
Question by:Micheal_Male
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 9

Assisted Solution

by:Graceful_Penguin
Graceful_Penguin earned 100 total points
ID: 24783820
Does have the row attribute/property  but it can only be used to limit the amount of rows in the textarea not to manipulate the content like a list view. But the attached code might help you in the right direction.
<html>
<head>
<title>Interactive Textarea</title>
</head>
<body>
<table style="text-align: left; width: 100px;" border="0" cellpadding="0" cellspacing="2">
<tbody>
<tr><td><input size="20" id="inputtext">
<input type="button" name="add" value="Add" onclick="addStuff()">
</td></tr>
<tr><td><textarea rows="15" id="textarea" name="box" cols="22"></textarea>
<input type = "button" name = "Delete" value = "Delete" onclick="deleteStuff()">;
</td></tr></tbody>
</table>
<br>
 
<script type = "text/javascript">
 
var oldText = new Array();
oldText[0] = "";
var i = 0; // global variable
 
function addStuff(){
var obj=document.getElementById('textarea');
obj.scrollTop=obj.scrollHeight;
 
if(document.getElementById('inputtext').value != "") {
oldText[i] = textarea.value;
document.getElementById('textarea').value+='" '+inputtext.value+'\n\n';
i++;
} 
}
 
function deleteStuff() {
if (i >= 1) {
document.getElementById('textarea').value = oldText[i-1];
i--;
var obj=document.getElementById('textarea');
obj.scrollTop=obj.scrollHeight;
 
}
}
 
</script>
 
</body>
</html>

Open in new window

0
 

Author Comment

by:Micheal_Male
ID: 24787218
Than for the reply actually it is a list box instead of a textatea I will try myself first and will post if I have any questions
0
 

Accepted Solution

by:
Micheal_Male earned 0 total points
ID: 24799549
I got the list box to worked as expected. Thanks for all your help :--).
0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Javascript Regex 7 20
Adding 1 the value of input "text" every 3 seconds 5 33
Table style position to the left 8 25
Hta File displays dynamic File names 4 46
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 …
Having worked on larger scale sites, we found out that you are bound to look at more scalable solutions to integrating widgets, code snippets or complete applications and mesh them into functional sites, in any given composition. To share some of…
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…

756 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