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

    Unhappy Throws the exception that the element is undefined.

    I have a paging control that dynamically adds the individual page numbers for the user to click on, but I noticed that the page didn't want to refresh.

    I did a lot of debugging and finally found where it was breaking; it's like it can't find the element h_page:

    Code:
        function do_Post(pageNum) {
            var frm = document.forms[0];
            try {
            frm.h_page.value = pageNum;
            frm.submit();  
            }
            catch(Error) {
                alert(Error.Message);
            }      
        }
    And then right at the top of the page I have to hidden variable:
    Code:
     <input type="hidden" id="h_page" value=""/>
    What could be causing this? I've been stuck on this for a while and none of my googling has brought back anything that has helped me.

  • #2
    Senior Coder
    Join Date
    Mar 2005
    Location
    Portsmouth UK
    Posts
    4,529
    Thanks
    3
    Thanked 511 Times in 498 Posts
    either give the input a name

    Code:
    <input type="hidden" name="h_page" value=""/>
    or

    Code:
    function do_Post(pageNum) {
            var frm = document.forms[0];
            try {
            document.getElementById('h_page').value = pageNum;
            frm.submit();
            }
            catch(Error) {
                alert(Error.Message);
            }
        }
    Vic

    God Loves You and will never love you less.

    http://www.vicsjavascripts.org/Home.htm

    If my post has been useful please donate to http://www.operationsmile.org.uk/

  • Users who have thanked vwphillips for this post:

    GarciaM (07-02-2012)

  • #3
    New to the CF scene
    Join Date
    Jul 2012
    Posts
    2
    Thanks
    1
    Thanked 0 Times in 0 Posts
    Thank you. The latter fixed my problem.
    Strange thing is that I have the same function on another website and there the former worked 100%.


  •  

    Tags for this Thread

    Posting Permissions

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