Forum Moderators: open

Message Too Old, No Replies

hidden fields not retaining information back button IE6.0.26

         

natty

2:48 pm on Mar 27, 2003 (gmt 0)

10+ Year Member



hopefully the topic says it all, i have a hidden field, being used to hold data for a possible back button, sort of like a cookie.
on NN4/6, IE5.x all is well. i am able to get the data from the field via
document.forms[0].fieldname.value
or
document.getelementbyid('fieldID').value

but IE 6.0.26/6.0.28 it just wont do it..
anyone know a work around.. apart from using cookies.

any help would be great

thanks

nathan

takagi

3:05 pm on Mar 27, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Something like this should also work in IE6.0.26

if(document.getElementById)
document.getElementById("fieldID").value= 5;
else if(document.all)
document.all.fieldID.value= 5;

natty

3:23 pm on Mar 27, 2003 (gmt 0)

10+ Year Member



thanks dude, but setting it is not the problem. i can set it fine, its retrieving it having backed a page to it, having ofc submitted a page setting it beforehand.

here is my code - i hope there isnt too much of it.. :s

<html .....
<input type=hidden name=holdvals id=holdvals>
..../html>

function saveVals(){
var i,j,theField,cookieString;
for (i = 0;i<fieldsToSave.length;i++){
var savedVals = new Array();
theField = eval('document.forms[0].' + fieldsToSave[i]);
for (j = 0;j < theField.length;j++){
savedVals[j] = [theField.options[j].value, theField.options[j].text];
if(j == theField.options.length-1){savedVals[j+1] = theField.selectedIndex;}
}

var saveString = savedVals.join('+');
cookieString += saveString + '!';
}
document.getElementById('holdvals').value = cookieString
}

function loadVals(){
var i,x,theField,defItem, cookieVal, fieldToFill,fieldObj;
var valsArray = new Array();
inps = document.getElementById("holdvals");
cookieVal = inps.value;
if (!cookieVal){return;}
valsArray = cookieVal.split('!');
for (i = 0;i < valsArray.length-1;i++){
//loop round each saved fields value
var fieldVals = new Array();
var itemArray = new Array();
fieldObj = 'document.forms[0].' + fieldsToSave[i]
fieldToFill = eval(fieldObj);
fieldVals = valsArray[i].split('+');
//for the return/single field
for (x=0;x<fieldVals.length;x++){
//loop round all the field options
if (x == fieldVals.length-1){defItem = fieldVals[x];break;}
itemArray[x] = [fieldVals[x].split(',')[0], fieldVals[x].split(',')[1]];
}
fillselect(fieldToFill, itemArray,0,defItem);
}
}

Xuefer

5:36 pm on Mar 27, 2003 (gmt 0)

10+ Year Member



try
header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT");

if you're using PHP