tsbarnes
01-07-2003, 03:41 PM
Ok,
I need a little help with keeping the values of my form after I do form validation. If the form returns an error than it wipes out my values in this javascript linked dropdowns I am using.
First of you can see the form @ www.object5.com/test/javascript.asp
Do the following to see the problem:
Fill out the form leaving out the partNumber. Also when you get to ProductType select Pt Items and for brand select other. Once you do this a text box will appear. You can put anything...test,ljjjkj, whatever you like.
Once you have done this click submit. If an error occurs it wipes out all of the value in the drop own menues. So my question is how do I hold those values? I pasted the javascript code below.
Code---------------------------------------------
</head>
<SCRIPT language="javascript">
<!-- hide jscript from old browsers ---
function refresh_screen()
{
window.location.reload()
}
/****** this object holds all of the key data **********/
function Link(name, url)
{
this.name = name;
this.title = new Array();
this.url = new Array();
}
/**************************************************************/
var names = new Array ();
var temp = new Array ();
var temp2 = new Array ();
var link = new Link ();
var final_list = new Array ();
/******** array declaration... it holds all of the data for the menus ****/
var menu = new Array (
"Bearings*" +
"|Choose Bearing Brand#" +
<%objRS6.MoveFirst%><%Do While Not objRS6.EOF%>
"<%=objRS6("BrandFull")%>|<%=objRS6("BrandFull")%>#" +
<%objRS6.MoveNext%><%Loop%>
"4|Other",
"PT Items*" +
"|Choose PT Brand#"+
<%objRS7.MoveFirst%><%Do While Not objRS7.EOF%>
"<%=objRS7("BrandFull")%>|<%=objRS7("BrandFull")%>#"+
<%objRS7.MoveNext%><%Loop%>
"4|Other",
"Seals*" +
"|Choose Seals Brand#"+
<%objRS8.MoveFirst%><%Do While Not objRS8.EOF%>
"<%=objRS8("BrandFull")%>|<%=objRS8("BrandFull")%>#"+
<%objRS8.MoveNext%><%Loop%>
"4|Other");
/*****************************************************************/
function updateMenus ( what ) {
var n = what.selectedIndex;
what.form.brand.length = final_list[n].title.length;
for (var x = 0; x < what.form.brand.length; x++)
{
what.form.brand.options[x].text = final_list[n].title[x];
what.form.brand.options[x].value = final_list[n].url[x];
}
what.form.brand.selectedIndex = 0;
}
/**************************************************************/
function give_names ()
{
document.myForm.producttype.length = names.length;
document.myForm.brand.length = final_list[0].title.length;
for ( var i=0; i<names.length; i++ )
document.myForm.producttype.options[i].text = final_list[i].name;
for (var x=0; x<final_list[0].url.length; x++)
document.myForm.brand.options[x].value = final_list[0].url[x];
for (var x=0; x<final_list[0].title.length; x++)
document.myForm.brand.options[x].text = final_list[0].title[x];
}
/**************************************************************/
function createMenus () {
for ( var i=0; i < menu.length; i++ )
{
names[i] = menu[i].split("*");
link = new Link(names[i][0]);
temp[i] = names[i][1].split("#");
final_list[i] = link;
for (var x=0; x<temp[i].length; x++)
{
temp2[x] = temp[i][x].split("|");
final_list[i].url[x] = temp2[x][0];
final_list[i].title[x] = temp2[x][1];
}
}
give_names();
}
/**************************************************************/
// end jscript hiding -->
</SCRIPT>
<body onLoad="createMenus(); document.myForm.PartNumber.focus()">
-----------------------------------------------------------------------------------
Any help will be most appreciated!
Thanks,
Tsbarnes
I need a little help with keeping the values of my form after I do form validation. If the form returns an error than it wipes out my values in this javascript linked dropdowns I am using.
First of you can see the form @ www.object5.com/test/javascript.asp
Do the following to see the problem:
Fill out the form leaving out the partNumber. Also when you get to ProductType select Pt Items and for brand select other. Once you do this a text box will appear. You can put anything...test,ljjjkj, whatever you like.
Once you have done this click submit. If an error occurs it wipes out all of the value in the drop own menues. So my question is how do I hold those values? I pasted the javascript code below.
Code---------------------------------------------
</head>
<SCRIPT language="javascript">
<!-- hide jscript from old browsers ---
function refresh_screen()
{
window.location.reload()
}
/****** this object holds all of the key data **********/
function Link(name, url)
{
this.name = name;
this.title = new Array();
this.url = new Array();
}
/**************************************************************/
var names = new Array ();
var temp = new Array ();
var temp2 = new Array ();
var link = new Link ();
var final_list = new Array ();
/******** array declaration... it holds all of the data for the menus ****/
var menu = new Array (
"Bearings*" +
"|Choose Bearing Brand#" +
<%objRS6.MoveFirst%><%Do While Not objRS6.EOF%>
"<%=objRS6("BrandFull")%>|<%=objRS6("BrandFull")%>#" +
<%objRS6.MoveNext%><%Loop%>
"4|Other",
"PT Items*" +
"|Choose PT Brand#"+
<%objRS7.MoveFirst%><%Do While Not objRS7.EOF%>
"<%=objRS7("BrandFull")%>|<%=objRS7("BrandFull")%>#"+
<%objRS7.MoveNext%><%Loop%>
"4|Other",
"Seals*" +
"|Choose Seals Brand#"+
<%objRS8.MoveFirst%><%Do While Not objRS8.EOF%>
"<%=objRS8("BrandFull")%>|<%=objRS8("BrandFull")%>#"+
<%objRS8.MoveNext%><%Loop%>
"4|Other");
/*****************************************************************/
function updateMenus ( what ) {
var n = what.selectedIndex;
what.form.brand.length = final_list[n].title.length;
for (var x = 0; x < what.form.brand.length; x++)
{
what.form.brand.options[x].text = final_list[n].title[x];
what.form.brand.options[x].value = final_list[n].url[x];
}
what.form.brand.selectedIndex = 0;
}
/**************************************************************/
function give_names ()
{
document.myForm.producttype.length = names.length;
document.myForm.brand.length = final_list[0].title.length;
for ( var i=0; i<names.length; i++ )
document.myForm.producttype.options[i].text = final_list[i].name;
for (var x=0; x<final_list[0].url.length; x++)
document.myForm.brand.options[x].value = final_list[0].url[x];
for (var x=0; x<final_list[0].title.length; x++)
document.myForm.brand.options[x].text = final_list[0].title[x];
}
/**************************************************************/
function createMenus () {
for ( var i=0; i < menu.length; i++ )
{
names[i] = menu[i].split("*");
link = new Link(names[i][0]);
temp[i] = names[i][1].split("#");
final_list[i] = link;
for (var x=0; x<temp[i].length; x++)
{
temp2[x] = temp[i][x].split("|");
final_list[i].url[x] = temp2[x][0];
final_list[i].title[x] = temp2[x][1];
}
}
give_names();
}
/**************************************************************/
// end jscript hiding -->
</SCRIPT>
<body onLoad="createMenus(); document.myForm.PartNumber.focus()">
-----------------------------------------------------------------------------------
Any help will be most appreciated!
Thanks,
Tsbarnes