This week's giveaway is in the Spring forum.
We're giving away four copies of Microservices Testing (Live Project) and have Chris Love & Andres Sacco on-line!
See this thread for details.
Win a copy of Microservices Testing (Live Project) this week in the Spring forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
Sheriffs:
  • Liutauras Vilda
  • Henry Wong
  • Devaka Cooray
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Al Hobbs
  • Carey Brown
Bartenders:
  • Piet Souris
  • Mikalai Zaikin
  • Himai Minh

History issue and JavaScript

 
Ranch Hand
Posts: 838
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
I have a html page with some javascript functions on the page and a dropdown list. I have a inline call to a series of functions on the page (near the bottom of the page - 2 in total) that work when the page loads up on initial call. If I choose the second, third, etc.., value in the dropdown list, submit the page, and go the action path everything is fine, no problems whatsoever. If I decide to go back to the previous page using the back button the inline script gets called but it tries to use the first value in the dropdown list I have on the page (i.e. doesn't use the value I selected) and once the script finishes the value gets reset to what it was before the page got submitted. No where in the code do I reset the dropdown value anywhere. It's like the script kicks in and finishes before values get set back accordingly. Is there a way to easily check to see if the page has loaded entirely before kicking off the inline calls? I'd appreciate any help on this, thanks in advance.

Rob
 
Rob Hunter
Ranch Hand
Posts: 838
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Disregard the AJAX bit in the subject, should have been simply Javascript.
 
author
Posts: 15385
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
what is the mystery code that is not reading the selected value?

Eric
 
Rob Hunter
Ranch Hand
Posts: 838
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Eric,
Was hoping I didn't have to post any code because of the amount of code involved. I found out what the problem was. I had window.onload = functionname(); but instead I did this => window.onload = function() { functionname(); }; Now it works fine. Thanks for getting back to me.

Rob
 
Sheriff
Posts: 67650
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

window.onload = function() { functionname(); };




 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic