...

View Full Version : Storing Variables



TravisMath
03-20-2005, 02:47 AM
In this code:


function storeFormVals()
{
theForm = document.getElementById("formname");
myArray=new Array();
for (i=0;i<theForm.elements.length;i++)
{
myArray[theForm.elements[i].name] = theForm.elements[i].value;
}
navigator.myvalues = myArray;
}

function restoreFormVals()
{
theForm = document.getElementById("formname");
if (!navigator.myvalues) return;

for (i=0;i<theForm.elements.length;i++)
{
theForm.elements[i].value = navigator.myvalues[theForm.elements[i].name];
}
}



What would you write in a document.write function to display only one form value onto the other page. I'm pretty sure this has to use an external JS file.

Philip M
03-20-2005, 09:11 AM
Change

for (i=0;i<theForm.elements.length;i++)
{
theForm.elements[i].value = navigator.myvalues[theForm.elements[i].name];
}

to

i = the single element you wish to display
theForm.elements[i].value = navigator.myvalues[theForm.elements[i].name];



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum