To all,
I have a page written on JavaScript that populates values into two listboxes. After you choose a value and click on it you go to a certain page. Now, if you want to search a different value and hit back the values in the second listbox are not displayed correctly when Explorer is used. What happens is that there is a number of default values that will be populated when the page gets loaded. Explorer always displays the default values while netscape acutally remembers what were the values you chose last and displays those. I would like to know if anyone could help me in fixing this problem when a user uses explorer. I know this is hard to explain so please visit the website below and see what I am talking about and take a look at the code.
I would greatly appreciate any help given!
Daniel
Here is the code:<SCRIPT LANGUAGE="JavaScript">
<!--
v=false;
//-->
</SCRIPT>
<SCRIPT LANGUAGE="JavaScript1.1">
<!--
if (typeof(Option)+"" != "undefined" v=true;
//-->
</SCRIPT>
<SCRIPT LANGUAGE="JavaScript">
<!--
if(v){a=new Array(22);}
function getFormNum (formName) {
var formNum =-1;
for (i=0;i<document.forms.length;i++){
tempForm = document.forms;
if (formName == tempForm) {
formNum = i;
break;
}
}
return formNum;
}
function jmp(form, elt)
// The first parameter is a reference to the form.
{
if (form != null) {
with (form.elements[elt]) {
if (0 <= selectedIndex)
location = options[selectedIndex].value;
}
}
}
var catsIndex = -1;
var itemsIndex;
if (v) { // ns 2 fix
function newCat(){
catsIndex++;
a[catsIndex] = new Array();
itemsIndex = 0;
}
function O(txt,url) {
a[catsIndex][itemsIndex]=new myOptions(txt,url);
itemsIndex++;
}
function myOptions(text,value){
this.text = text;
this.value = value;
}
// fill array
newCat();
O("South East","O("Mid-Atlantic","O("NC Inland","O("Chesapeake","O("New Jersey","O("New York","O("Michigan","O("Lake Michigan","O("Connecticut","O("Patriot","O("Lone Star","O("Rocky Mountain","O("Valley of the Sun","O("Cascades","O("So. California","O("No. California","O("International","O("None","
newCat();
O("Membership","O("Awards","O("Marketing","O("Program","O("Professional Development","O("Telecommuting","O("Inernational","O("Elections","
newCat();
O("Public Policy","O("TMA","O("Consultants","O("Non-Urban","O("Welfare to Work","O("Employer","O("Vanpool","O("Access to Jobs","
newCat();
O("Clean Air Chair","O("Director","O("Membership","O("Treasurer","O("Vice President","O("Secretary","O("Public Policy","O("Programs","O("Newsletter","O("Past President","
newCat();
O("Board Members","} // if (v)
function relate(formName,elementNum,j) {
if(v){
var formNum = getFormNum(formName);
if (formNum>=0) {
formNum++; // reference next form, assume it follows in HTML
with (document.forms[formNum].elements[elementNum]) {
for(i=options.length-1;i>0;i--) options = null; // null out in reverse order (bug workarnd)
for(i=0;i<a[j].length;i++){
options = new Option(a[j].text,a[j].value);
}
options[0].selected = true;
}
}
} else {
jmp(formName,elementNum);
}
}
function IEsetup(){
if(!document.all) return;
IE5 = navigator.appVersion.indexOf("5."!=-1;
if(!IE5) {
for (i=0;i<document.forms.length;i++) {
document.forms.reset();
}
}
}
window.onload = IEsetup;
//-->
</SCRIPT>
<CENTER>
<TABLE BGCOLOR="#99FFFF" BORDER="0" CELLPADDING="8" CELLSPACING="0">
<TR VALIGN="TOP"><TD>Choose a Category:<BR><FORM NAME="f1" METHOD="POST" ACTION="/cgi-bin/redirect.cgi" onSubmit="return false;">
<SELECT NAME="m1" ID="m1" CLASS=saveHistory onChange="relate(this.form,0,this.selectedIndex)"><OPTION VALUE="/Chapter/">Chapter<OPTION VALUE="/Committee/">Committee<OPTION VALUE="/Council/">Council<OPTION VALUE="/Directors">Directors<OPTION VALUE="/Board/">Board</SELECT><INPUT TYPE=SUBMIT VALUE="Go" onClick="jmp(this.form,0);">
</FORM></TD>
<TD BGCOLOR="#FFFFFF" VALIGN=MIDDLE><B>---></B></TD>
<TD>Choose a Criteria:<BR><FORM NAME="f2" METHOD="POST" ACTION="/cgi-bin/redirect.cgi" onSubmit="return false;">
<SELECT NAME="m2" ID="m2" CLASS=saveHistory onChange="jmp(this.form,0)">
<OPTION VALUE=" East
<OPTION VALUE="<OPTION VALUE=" Inland
<OPTION VALUE="<OPTION VALUE=" Jersey
<OPTION VALUE=" York
<OPTION VALUE="<OPTION VALUE=" Michigan
<OPTION VALUE="<OPTION VALUE="<OPTION VALUE=" Star
<OPTION VALUE=" Mountain
<OPTION VALUE=" of the Sun
<OPTION VALUE="<OPTION VALUE=" California
<OPTION VALUE=" California
<OPTION VALUE="<OPTION VALUE="<INPUT TYPE=SUBMIT VALUE="Go" onClick="jmp(this.form,0);">
<INPUT TYPE="hidden" NAME="baseurl" VALUE="</FORM></TD>
</TR>
</TABLE></CENTER>
[sig][/sig]
I have a page written on JavaScript that populates values into two listboxes. After you choose a value and click on it you go to a certain page. Now, if you want to search a different value and hit back the values in the second listbox are not displayed correctly when Explorer is used. What happens is that there is a number of default values that will be populated when the page gets loaded. Explorer always displays the default values while netscape acutally remembers what were the values you chose last and displays those. I would like to know if anyone could help me in fixing this problem when a user uses explorer. I know this is hard to explain so please visit the website below and see what I am talking about and take a look at the code.
I would greatly appreciate any help given!
Daniel
Here is the code:<SCRIPT LANGUAGE="JavaScript">
<!--
v=false;
//-->
</SCRIPT>
<SCRIPT LANGUAGE="JavaScript1.1">
<!--
if (typeof(Option)+"" != "undefined" v=true;
//-->
</SCRIPT>
<SCRIPT LANGUAGE="JavaScript">
<!--
if(v){a=new Array(22);}
function getFormNum (formName) {
var formNum =-1;
for (i=0;i<document.forms.length;i++){
tempForm = document.forms;
if (formName == tempForm) {
formNum = i;
break;
}
}
return formNum;
}
function jmp(form, elt)
// The first parameter is a reference to the form.
{
if (form != null) {
with (form.elements[elt]) {
if (0 <= selectedIndex)
location = options[selectedIndex].value;
}
}
}
var catsIndex = -1;
var itemsIndex;
if (v) { // ns 2 fix
function newCat(){
catsIndex++;
a[catsIndex] = new Array();
itemsIndex = 0;
}
function O(txt,url) {
a[catsIndex][itemsIndex]=new myOptions(txt,url);
itemsIndex++;
}
function myOptions(text,value){
this.text = text;
this.value = value;
}
// fill array
newCat();
O("South East","O("Mid-Atlantic","O("NC Inland","O("Chesapeake","O("New Jersey","O("New York","O("Michigan","O("Lake Michigan","O("Connecticut","O("Patriot","O("Lone Star","O("Rocky Mountain","O("Valley of the Sun","O("Cascades","O("So. California","O("No. California","O("International","O("None","
newCat();
O("Membership","O("Awards","O("Marketing","O("Program","O("Professional Development","O("Telecommuting","O("Inernational","O("Elections","
newCat();
O("Public Policy","O("TMA","O("Consultants","O("Non-Urban","O("Welfare to Work","O("Employer","O("Vanpool","O("Access to Jobs","
newCat();
O("Clean Air Chair","O("Director","O("Membership","O("Treasurer","O("Vice President","O("Secretary","O("Public Policy","O("Programs","O("Newsletter","O("Past President","
newCat();
O("Board Members","} // if (v)
function relate(formName,elementNum,j) {
if(v){
var formNum = getFormNum(formName);
if (formNum>=0) {
formNum++; // reference next form, assume it follows in HTML
with (document.forms[formNum].elements[elementNum]) {
for(i=options.length-1;i>0;i--) options = null; // null out in reverse order (bug workarnd)
for(i=0;i<a[j].length;i++){
options = new Option(a[j].text,a[j].value);
}
options[0].selected = true;
}
}
} else {
jmp(formName,elementNum);
}
}
function IEsetup(){
if(!document.all) return;
IE5 = navigator.appVersion.indexOf("5."!=-1;
if(!IE5) {
for (i=0;i<document.forms.length;i++) {
document.forms.reset();
}
}
}
window.onload = IEsetup;
//-->
</SCRIPT>
<CENTER>
<TABLE BGCOLOR="#99FFFF" BORDER="0" CELLPADDING="8" CELLSPACING="0">
<TR VALIGN="TOP"><TD>Choose a Category:<BR><FORM NAME="f1" METHOD="POST" ACTION="/cgi-bin/redirect.cgi" onSubmit="return false;">
<SELECT NAME="m1" ID="m1" CLASS=saveHistory onChange="relate(this.form,0,this.selectedIndex)"><OPTION VALUE="/Chapter/">Chapter<OPTION VALUE="/Committee/">Committee<OPTION VALUE="/Council/">Council<OPTION VALUE="/Directors">Directors<OPTION VALUE="/Board/">Board</SELECT><INPUT TYPE=SUBMIT VALUE="Go" onClick="jmp(this.form,0);">
</FORM></TD>
<TD BGCOLOR="#FFFFFF" VALIGN=MIDDLE><B>---></B></TD>
<TD>Choose a Criteria:<BR><FORM NAME="f2" METHOD="POST" ACTION="/cgi-bin/redirect.cgi" onSubmit="return false;">
<SELECT NAME="m2" ID="m2" CLASS=saveHistory onChange="jmp(this.form,0)">
<OPTION VALUE=" East
<OPTION VALUE="<OPTION VALUE=" Inland
<OPTION VALUE="<OPTION VALUE=" Jersey
<OPTION VALUE=" York
<OPTION VALUE="<OPTION VALUE=" Michigan
<OPTION VALUE="<OPTION VALUE="<OPTION VALUE=" Star
<OPTION VALUE=" Mountain
<OPTION VALUE=" of the Sun
<OPTION VALUE="<OPTION VALUE=" California
<OPTION VALUE=" California
<OPTION VALUE="<OPTION VALUE="<INPUT TYPE=SUBMIT VALUE="Go" onClick="jmp(this.form,0);">
<INPUT TYPE="hidden" NAME="baseurl" VALUE="</FORM></TD>
</TR>
</TABLE></CENTER>
[sig][/sig]