...

View Full Version : Adding text to textarea so that user can add/remove



Pervez
09-28-2012, 12:53 PM
Hi,

I want to add text from input filed to textarea or something like list box, form there the user can able to add/remove and delete single/multiple data from that box.

I try'd to out for two days for this , but am not getting exact solution for this.
How can i do this......??

here is my code,
<script type="text/javascript">
var max=10;
function update(){
var current=$('#div a').length,skills=[]
$('button,#input').button(current<max?'enable':'disable')
$('#div a').each(function(){
var skill=$(this).text()
skills.push(skill.substr(0,skill.length-2))
})
$('#skills').val(skills.join(';'))
}
$(function(){
$(':input').button()
$('button').click(function(){
var t=$(($('input').val()+ ' *'.small()).link('/query?'+$('input').val())).button()
$('#div').append(t.click(function(){
$(this).remove()
$('#input').focus()
update()
return false
}))
$('#input').val('').focus()
update()
return false
})
})
</script>
<style type="text/css">
#div a
{
border: 2px;
border-radius: 1px;
background-color: #D6D6D6;
color:#000000;
margin-right:1px;
}
#input { text-align: left !important; }
</style>
</head>
<body>
<input id="input" value="http://"/> <button>Add</button>
<div id="div"></div>
<form action="" method="POST">
<div class="b2"><b>Add Categories </b></div>
<textarea id="skills" type="text" name="Blacklist" rows="6" cols="59"/></textarea>
<input type="submit" value="Submit"><input type="Reset" value="Clear Form">
</form>


here the user added data getting in textarea and also adding on top of textarea,

Thank You
Pervez

sunfighter
09-28-2012, 05:21 PM
<!DOCTYPE html>
<html>
<head>
<script>
function opie()
{
document.getElementById('myplace').innerHTML = document.getElementById('myinput').value;
}
</script>
</head>

<body>
<form>
<input type="text" id="myinput" onkeyup="opie();"
<hr>
<hr>
<hr>
<textarea id="myplace" maxlength="20"></textarea>
</form>
</body>
</html>

list box is a M$ thing.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum