Internal HTML List

[Total: 0    Average: 0/5]

This allows the user to enter data and add it to a list that is kept internal to the document.

Head Code:

      <SCRIPT language=JavaScript>
<!-- hide it ...
function MakeArray( n ) {
if( n <= 0 ) {
this.length = 0;
return this;
}
this.length = n;
for( var i = 1; i <= n; i++ ) {
this[ i ] = 0;
}
return this;
}
var history1 = new MakeArray( 25 );
var index = 0;
var cmmnd = 1;
function f_store( sTR ) {
var i;
if( index >= history1.length ) {
for( i = 1; i < history1.length; i++ )
history1[i-1] = history1[i];
index = history1.length - 1;
}
history1[ index ] = cmmnd + ":" + sTR;
++cmmnd;
++index;
document.history1.command.value="";
}
function f_print() {
var allCmmnds, i;
allCmmnds = "";
for( i = 0; i < index; i++ )
allCmmnds += history1[i] + "n";
alert( allCmmnds );
}
// End -->
</SCRIPT>

Body Code:

<FORM name=history1>
<INPUT name=command>
<INPUT onclick=f_store(document.history1.command.value) type=button value="Add to List"> 
<INPUT name=history1 onclick=f_print() type=button value="Show List"> 
</FORM>      

Times Viewed: 1

Leave a Reply

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