Re: JavaScript & Select

by "Norman Bunn" <norman.bunn(at)craftedsolutions.com>

 Date:  Mon, 18 Sep 2000 15:13:55 -0400
 To:  <hwg-languages(at)hwg.org>
 References:  FSODOM
  todo: View Thread, Original
The interesting thing is the page maintains the updated information when
resubmitted, unless it is changed to "1".  Apparently, the array for the
select statement is refreshed to the initial setup on using the BACK button,
but the selected option is maintained even if it does not appear on the
option list.

Any ideas on how to get the page to work properly when the BACK button is
pressed?

Norman

----- Original Message -----
From: Norman Bunn <norman.bunn(at)craftedsolutions.com>
To: <hwg-languages(at)hwg.org>
Sent: Wednesday, September 13, 2000 1:10 PM
Subject: JavaScript & Select


> I have a page with the following HTML.
>
> <BODY BGCOLOR="#FFFFFF" BODY="onLoad=packageQty()">
> <input type=text name=Quantity value=1 size=4 maxlength=4
> onChange="packageQty()">
> <SELECT NAME=PKG_Qty_02><OPTION VALUE=1 selected>1</OPTION></SELECT>
>
> When the value in the quantity field is changed or the page loads, the
> option list changes based on the JavaScript function below.  Everything
> works as expected, except when the form is submitted and then the BACK
> button is pressed.  Instead of a list matching the quantity value, I get a
> blank option displayed with "1" as the only other option.  This happens
only
> when the quantity is changed before submitting.  Ideally what I would like
> is for the items to reflect their values immediately prior to submission.
> Any ideas on how to make this work correctly?
>
> function packageQty()
>
>     for (var i=0; i<document.submit.elements.length; i++)
>
>
>         if (document.submit.elements[i].type ==
>
t-one"){ 
>             var valString = document.submit.elements[i].name; 
>             if (valString.match(/(PKG_Qty_)/)){ 
>                 for (var j=1; j<=document.submit.Quantity.value; j++) 
>                 { 
>                     document.submit.elements[i].options[j-1] = new Option(j,j,document.submit.Quantity.value,document.submit.Quantity.value);
>                 } 
>             } 
>         } 
>     } 
> } 

>
>
>

HWG: hwg-languages mailing list archives, maintained by Webmasters @ IWA

This page is part of a preserved archive of archives.hwg.org. The site is no longer active and its content is not maintained. For enquiries about this archive, write to archive(at)iwanet.org.