[thelist] Javascript Back Button Issue

Feingold Josh S Josh.S.Feingold at irs.gov
Wed May 1 13:53:01 CDT 2002


This message is in MIME format. Since your mail reader does not understand
this format, some or all of this message may not be legible.
--
[ Picked text/plain from multipart/alternative ]
I have a multipage form.  The values for each page are stored in a cookie.
When the user hits the back button, I want the cookie values to appear in
the form.

The problem that I am finding is that when the user hits the back button,
the values for the text input fields correctly display, but for the select
box are defaulted to the value before they went to the next page.  If I hit
refresh all values are correct. I don't understand why the two form objects
would act differently.

If you can help, I would be appreciative.

Here is some of the code:

	cookie = "<%= request.cookies("new_cr") %>"   //Cookie comes from
ASP format "value','value"
    new_cr = cookie.split("','")

    for (x=0;x<new_cr.length;x++) {
     new_cr[x] = new_cr[x].replace(/''/g,"'")
    }

    //Insert easy fields (simple text input)
    fields = new
Array("originator_name","originator_title","originator_phone","originator_em
ail","bod_name","originator_approv_director_name","originator_approv_directo
r_phone","originator_approv_director_email","request_title","request_ops_dat
e","request_change_type","request_reason_for_change","bill_number")
    easyfields = new Array(0,1,2,3,5,6,7,8,9)

    for (x=0;x<easyfields.length;x++) {
     document.submit_cr.elements[fields[easyfields[x]]].value =
new_cr[easyfields[x]]
    }



    // Set up select boxes
    for (x=0;x<document.submit_cr.request_reason_for_change.length;x++) {
     if (document.submit_cr.request_reason_for_change.options[x].value ==
new_cr[11]) {
      document.submit_cr.request_reason_for_change.options[x].selected =
true
     }
    }

    for (x=0;x<document.submit_cr.bod_name.length;x++) {
     if (document.submit_cr.bod_name.options[x].value == new_cr[4]) {
      document.submit_cr.bod_name.options[x].selected = true
     }
    }

    // Set up multiple select box
    changetype = new_cr[10].split(", ")

    for (y=0;y<document.submit_cr.request_change_type.length;y++) {
     for (x=0;x<changetype.length;x++) {
      if (document.submit_cr.request_change_type.options[y].value ==
changetype[x] ) {
       document.submit_cr.request_change_type.options[y].selected = true
      }
     }
    }

Josh



More information about the thelist mailing list