Insert Text into Text Box

They have: 51 posts

Joined: Dec 2002

Anyone know if it's possible to insert text into a box upon clicking a button? I know it's possible via drop-down menus so I guess it's possible via button clicking.

The text would need to add to what is already in the box, not just clear the contents and display it's self.

Abhishek Reddy's picture

He has: 3,348 posts

Joined: Jul 2001

Something like this?

<script type="text/javascript">
  function addText(theText)
    {
      document.getElementById("box").value += theText;
    }
</script>

<input type="text" id="box" value="something">
<input type="button" onclick="addText(' something more')" value="Add more text">
'

They have: 51 posts

Joined: Dec 2002

cheers, just what I was after

Want to join the discussion? Create an account or log in if you already have one. Joining is fast, free and painless! We’ll even whisk you back here when you’ve finished.