Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 6 of 6
  1. #1
    New Coder
    Join Date
    Jul 2002
    Location
    Florida
    Posts
    60
    Thanks
    0
    Thanked 0 Times in 0 Posts

    onClick -- reload page possible?

    Is it possible to have JS reload the page via an onClick event?

    Depending on what the user chooses in one list box, I have some other list boxes I want to repopulate (via other scripts) and simply want to force a reload of the page so the scripts will run.

    I don't know what this reload event looks like in JS.

    Thanks in advance.

  • #2
    Senior Coder
    Join Date
    Jun 2002
    Location
    Nashua, NH
    Posts
    1,724
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Why on earth do you need to reload the page to make scripts run. Especially those that populate form elements...
    What happened to puting the script you need to execute in a function and running it onclick?
    Vladdy | KL
    "Working web site is not the one that looks the same on common graphical browsers running on desktop computers, but the one that adequately delivers information regardless of device accessing it"

  • #3
    New Coder
    Join Date
    Jul 2002
    Location
    Florida
    Posts
    60
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Here is why.

    I write most of my scripts in PHP, with an occasional Jscript as needed for client side stuff. But Jscript is notoriously buggy across platforms and browsers. PHP is pretty solid.

    Also, unlike JS, PHP is pretty straightforward to program in. Anybody that know C or C++ can pick it up in a couple of weeks, or less. And I don't know JS all that well.

    I have two list boxes on a form. One is a list for languages, German, French, English, etc. The other is a list of months. When the user changes languages, the months list also change. This works fine in some browsers, but not others. Netscape 4.7 esp. does not like this stuff, while NS 7.0 and IE 5.5 like it just fine.

    My plan is to re-implement those list boxes in PHP. I already have code to do that. I also send the user a cookie when he selects his language choice for his default. So by reloading the page with onClick (in the language list box, and yes, I can intermingle JS with PHP, but not the other way around) I will grab the cookie and refresh the list boxes as needed.

    I would like to do this all in JS. But as stated, it's just to unreliable and is causing to many problems across browsers.

    Can you tell me if it's possible to have the onClick event call something to reload the page.

    Thanks.

  • #4
    Senior Coder
    Join Date
    Jun 2002
    Location
    Nashua, NH
    Posts
    1,724
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Seems like too much trouble to keep minority happy
    window.location.href = 'filename.html' should reload the page
    Vladdy | KL
    "Working web site is not the one that looks the same on common graphical browsers running on desktop computers, but the one that adequately delivers information regardless of device accessing it"

  • #5
    New Coder
    Join Date
    Nov 2002
    Location
    Netherlands
    Posts
    78
    Thanks
    0
    Thanked 0 Times in 0 Posts
    onClick (or any other event handler)="window.location.reload()"

  • #6
    New Coder
    Join Date
    Jul 2002
    Location
    Florida
    Posts
    60
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Smile PHP + JS, works great now !

    Thanks, that's just what I was looking for.

    Now when the user selects a different language in the list box, the onClick event calls a JS function that :

    1. sends a new language cookie

    2. reloads the page

    The PHP scripts then run, and the list boxes get rebuilt with the correct data (by checking the language cookie). Works great, if you don't mind the temporary server delay in reloading the page. But it's a much simpler design than what I had when trying to do this all in JS.

    PHP and JS can be a terrific combo, if you know how to mix them.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •