Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    New Coder
    Join Date
    Jul 2012
    Posts
    15
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Adding text to textarea so that user can add/remove

    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

  • #2
    Senior Coder
    Join Date
    Jan 2011
    Location
    Missouri
    Posts
    3,763
    Thanks
    23
    Thanked 548 Times in 547 Posts
    Code:
    <!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.


  •  

    Tags for this Thread

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •