|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
Hi Friends,
this problem really has me stumped. I am using the body onLoad to initialise a couple of <SELECT> boxes. These boxes have a lot of options ( e.g. list of all countries) and using server-side coding to select the appropriate option is time consuming and also causes server time-outs. So i handed it over to the client=side. the onload calls a procedure that loops thru the <SELECT> box and selects the option whose value matches the one i write into a hidden tag thru ASP. so i have a hidden field with value="India". then i would loop thru the <SELECT> box of all countries and when i find the option with the value "India", i set the selectedIndex to that, selected=true and defaultSelected=true. This works fine, but then i discovered another problem. If i post this form and go onto the next step, when i press the Back button on the browser, and go back to the last page, the onLoad fires again and instead of retaining the value i might have selected ( supposing i changed the country to "United States" from "India"), it sets it back to "India". how can i prevent this??? any ideas? I tried using a hidden field called "Back" and on form submit, setting its value to "Y". This value persists, when i come back to this page. so then the "United States" option stays selected but this only works in IE not NS...... any ideas on what i can do?? the basic solution i want is to know whether the pages is being loaded for the first time.. then i do the initialisation and if the page is being loaded from the cache by clicking the "back" button, i bypass the initilisation. --- pseudo-code follows ----- <script language=JavaScript> function setUp(){ if (fresh_load){ initialise_all_form_elements } } </script> <body onLoad="setUp();"> all input welcome Thanks |
![]() |
| Viewing: Dev Shed Forums > Web Design > HTML Programming > Body onLoad problem |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|
|