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 5 of 5
  1. #1
    New to the CF scene
    Join Date
    Dec 2007
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    creating an object and calling function in event handler

    Hi

    I have trouble in executing the following part of code. can anyone help on it

    <input type="button" value="Go" onclick="
    var pager = new Pager('results',10);
    pager.init();
    pager.showPageNav('pager', 'pageNavPosition');
    pager.showPage(1);return false;
    " />

    whenever i execute this code, i get an error that pager is undefined.But if i put this line "var pager = new Pager('results',10);" in a separate script then it works fine.. so please help me in this issue.

  • #2
    Supreme Master coder! abduraooft's Avatar
    Join Date
    Mar 2007
    Location
    N/A
    Posts
    14,853
    Thanks
    160
    Thanked 2,223 Times in 2,210 Posts
    Blog Entries
    1
    Code:
    <script type="text/javascript">
    function show()
    {
    var pager = new Pager('results',10);
    pager.init();
    pager.showPageNav('pager', 'pageNavPosition');
    pager.showPage(1);return false;
    }
    </script>
    Code:
    <input type="button" value="Go" onclick="show();" />
    ?
    The Dream is not what you see in sleep; Dream is the thing which doesn't let you sleep. --(Dr. APJ. Abdul Kalam)

  • #3
    New to the CF scene
    Join Date
    Dec 2007
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Even this i tried.. same error occurs....

  • #4
    Kor
    Kor is offline
    Red Devil Mod Kor's Avatar
    Join Date
    Apr 2003
    Location
    Bucharest, ROMANIA
    Posts
    8,478
    Thanks
    58
    Thanked 379 Times in 375 Posts
    should pager variable be a global? In this case:
    Code:
    ... onclick="pager=new Pager('results',10);..."
    KOR
    Offshore programming
    -*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*

  • #5
    New to the CF scene
    Join Date
    Dec 2007
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts
    If it is a global variable .then the logic doesnt work properly


  •  

    Posting Permissions

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