Results 1 to 2 of 2

Thread: Select all text in textarea button.

  1. #1
    Join Date
    Oct 2010

    Question Select all text in textarea button.

    I have a form with a <textarea> and a <button>. I would like users to be able to select (highlight) all text in the textarea by clicking the button. I know this is possible with <input type="button"> but I can't seem to get it to work with a button tag. Could someone help me out please?

    this is what i have so far:

    <textarea id="messageBody" style="width:100%;height:200px;border:1px solid #999;" wrap="off"></textarea>
    <button onClick="javascript:this.form.frm.focus();this.form.frm.select();" style="background-image:url('images/gradiant_2.png');" class="buttonstylessm">Select All</button>

    Thanks in advance,

  2. #2
    Join Date
    May 2009

    try this

    <form name="selectall">
    <textarea name="messageBody" style="width:100%;height:200px;border:1px solid #999;" wrap="off" ></textarea>
    <br />
    <input type="button" value="Select Text" onClick="javascript:this.form.messageBody.focus();this.form.messageBody.select();">

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

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
HTML5 Development Center