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 2 of 2
  1. #1
    Regular Coder
    Join Date
    Sep 2006
    Posts
    216
    Thanks
    9
    Thanked 0 Times in 0 Posts

    page reload and call a function

    Hey,

    Is it possible to create an onclick event which reloads the page and passes a parameter into a javascript function automatically?

    Any code snippets would be appreciated.

    Thank you in advance

  • #2
    New Coder
    Join Date
    Dec 2006
    Posts
    80
    Thanks
    1
    Thanked 0 Times in 0 Posts
    If you're trying to do what I think you are then:

    <button name = "but1" onclick = "javascript:document.form1.field1.value = "whatever"; window.location.reload()")>Reload Page</button> <!--use a hidden field to store the value of your parameter before the page reloads-->

    <body onload = "myScript(document.form1.field1.value)"><!--reference the hidden field's value at load time-->
    <script language = "javascript">
    function myScript(myParam)
    {
    alert(myParam)
    }
    </script>

    I think this should work.
    HTH
    Joe
    Last edited by LFCFan; 02-06-2007 at 04:14 PM.


  •  

    Posting Permissions

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