DHTML – Insert and Remove Text

[Total: 0    Average: 0/5]

Insert HTML with a click of a button.

Head Code:

<script>
var STATE=1;
var MSG=new Array();
MSG[0]="You clicked";
MSG[1]="";
function fun_nb()
{
  STATE=(STATE+1)%2;
  var my_msg=MSG[STATE];
  document.getElementById('test').innerHTML=my_msg;
}
</script>

Body Code:

<HR>
<span id="test"></span>
<HR>
<form>
<input type=button value="click here" onclick="fun_nb();" >
<BR>
<input type=button value="alert here" onclick="alert('message here');" >
</form>

Times Viewed: 10

Leave a Reply

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