Script Categories













Forms >>> Items List.

Javascript can remember a list of several items you enter. Just enter an item and click 'Add to List'. When you are finished, click 'Show List' to see the entries.

Add the below code to the <body> section of your page:

<FORM name="historY">
<INPUT
name="command" type="text" value="">
<INPUT
type="button" value="Add to List" onclick="f_store(document.historY.command.value)">
<INPUT
name="historY" type="button" value="Show List" onclick="f_print()">
</FORM>
<script language="javascript" type="text/javascript">
/* Visit http://www.yaldex.com/ for full source code
and get more free JavaScript, CSS and DHTML scripts! */
<!-- 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 historY = new MakeArray( 15 );
var index = 0;
var cmmnd = 1;
function f_store( sTR ) {
var i;
if( index >= historY.length ) {
for( i = 1; i < historY.length; i++ )
historY[i-1] = historY[i];
index = historY.length - 1;
}
historY[ index ] = cmmnd + ":" + sTR;
++
cmmnd;
++
index;
document.historY.command.value="";
}
function f_print() {
var allCmmnds, i;
allCmmnds = "";
for( i = 0; i < index; i++ )
allCmmnds += historY[i] + "\n";
alert( allCmmnds );
}
// End -->
</script>

JavaScript Editor Get Advanced
JavaScript and Ajax Editor,
Validator and Debugger!

1st JavaScript Editor.



Code was highlighted by 1st JavaScript Editor (The Best JavaScript Editor!).




©