Go Back   CodingForums.com > :: Client side development > JavaScript programming

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 07-02-2012, 11:54 AM   PM User | #1
GarciaM
New to the CF scene

 
Join Date: Jul 2012
Posts: 2
Thanks: 1
Thanked 0 Times in 0 Posts
GarciaM is an unknown quantity at this point
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.
GarciaM is offline   Reply With Quote
Old 07-02-2012, 12:24 PM   PM User | #2
vwphillips
Senior Coder

 
Join Date: Mar 2005
Location: Portsmouth UK
Posts: 4,353
Thanks: 3
Thanked 456 Times in 443 Posts
vwphillips is a jewel in the roughvwphillips is a jewel in the roughvwphillips is a jewel in the rough
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.uk/

If my post has been useful please donate to http://www.operationsmile.org.uk/
vwphillips is offline   Reply With Quote
Users who have thanked vwphillips for this post:
GarciaM (07-02-2012)
Old 07-02-2012, 12:31 PM   PM User | #3
GarciaM
New to the CF scene

 
Join Date: Jul 2012
Posts: 2
Thanks: 1
Thanked 0 Times in 0 Posts
GarciaM is an unknown quantity at this point
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%.
GarciaM is offline   Reply With Quote
Reply

Bookmarks

Tags
submit, value of element

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 06:18 PM.


Advertisement
Log in to turn off these ads.