...

View Full Version : window.history Question



jacQuestion
02-04-2004, 01:50 AM
Hi Everyone !

I am new to javascript and encountering a problem I can not work thru.

This is my situation.

I have a form which contains a checkbox. Based on whether or not that box is checked I enable 3 other checkboxes and a text field.

<input onblur='window.status="";' onfocus='window.status="Select Box,
if you want your backup to go to tape media. Otherwise backup will go to disk on
ly";' type=checkbox name=dailybackup_backupToTapeFlag onClick="setBoxes();">

I have written a function which tests the condition of the controlling checkbox and sets the other fields accordingly. (That works fine)

The problem comes in when I advance to the next screen with the controlling checkbox checked and the subordinates enabled and populated, I provide a back button on the next screen which is using window.history.go(-1). When I test the back functionality. I return to the previous window and msie has the status of the controlling checkbox as "false".

In Netscape it does not seem to have a problem knowing the state of the controlling checkbox when I return. Does anyone know what the problem is?

My function is as follows:

function setBoxes(){
myForm=window.document.forms[0];

tapeCheckbox=myForm.dailybackup_backupToTapeFlag;
alert("tapeCheckbox is checked: " + tapeCheckbox.checked
+ "\nValue of tapeCheckBox is: " + tapeCheckbox.value
+ "\nName of tapeCheckBox is: " + tapeCheckbox.name);
reportsCheckbox=myForm.dailybackup_ADD_report;
usersCheckbox=myForm.dailybackup_ADD_users;
programsCheckbox=myForm.dailybackup_ADD_programs;
additionalsCheckbox=myForm.dailybackup_ADD_additionals;

if (tapeCheckbox.checked == false){
alert("TapeCheckbox is checked: " + tapeCheckbox.checked
+ "\nWill disable and checked=off");
reportsCheckbox.checked=false;
reportsCheckbox.disabled=true;
usersCheckbox.checked=false;
usersCheckbox.disabled=true;
programsCheckbox.checked=false;
programsCheckbox.disabled=true;
additionalsCheckbox.value = "";
additionalsCheckbox.disabled=true;
additionalsCheckbox.style.backgroundColor="#D4D0C8";
} else {
alert("TapeCheckbox is checked: " + tapeCheckbox.checked
+ "\nWill enable");
reportsCheckbox.disabled=false;
usersCheckbox.disabled=false;
programsCheckbox.disabled=false;
additionalsCheckbox.disabled=false;
additionalsCheckbox.style.backgroundColor="#ffffff";
}
}
alert("Executing bottom");
setBoxes();

Thanks In Advance !

jacQuestion

joh6nn
02-04-2004, 02:44 AM
this has to do with the way the two browsers are programmed. Netscape/Mozilla remembers form input, IE doesn't. there's not much you can do about it, short of saving the information to a cookie

jacQuestion
02-04-2004, 02:53 AM
What is interesting about IE's behavior is that when the back button is clicked and the history -1 takes effect. IE knows the controlling checkbox was selected because it is checked.

Also if I place, <body onLoad=setboxes();>

IE behaves appropriately. Unfortunately our <body> statement is buried in an include and used by all pages to set static ui data.
It would take quite a little refactoring to use this method.

Appreciatively,

Jim



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum