Click Button – Swap Contents

[Total: 0    Average: 0/5]

This will swap textarea data between two boxes when you click on the button.

Head Code:

<script>
function switchem()
{
  var _form=document.ex1;
  var _object1=_form.t1;
  var _object2=_form.t2;
  var _temp=_object1.value;
  _object1.value=_object2.value;
  _object2.value=_temp;
}
</script>

Body Code:

<form name=ex1>
<textarea name=t1>ABC</textarea>
<input type=button value="Switch" onclick=switchem()>
<textarea name=t2>DEF</textarea>
</form>

Times Viewed: 4

Leave a Reply

Your email address will not be published. Required fields are marked *