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
    Aug 2002
    Location
    Henderson, NV
    Posts
    21
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Angry Accessing form data within layer

    Greets all,

    I have a page that has a couple forms hidden within layers. I use these multiple forms to funnel to a centralized form, which then calls the primary script to grab stuff from a database.

    I'm trying to get the data of a form (via simple JavaScript) from the 'biblenav' form in the 'openmenu' layer and pass it to the root form 'query'. Here's what my JavaScript looks like:

    function start_nav()
    {
    bookindex = document.openmenu.biblenav.book_select.selectedIndex;
    chapterindex = document.openmenu.biblenav.chapter_select.selectedIndex;
    versionindex = document.openmenu.biblenav.version_select.selectedIndex;
    commindex = document.openmenu.biblenav.notes_select.selectedIndex;
    book = document.openmenu.biblenav.book_select[bookindex].value;
    chapter = document.openmenu.biblenav.chapter_select[chapterindex].value;
    verse = 0;
    version = document.openmenu.biblenav.version_select[versionindex].value;
    commtype = document.openmenu.biblenav.comm_select[commindex].value;
    document.query.book.value = book;
    document.query.chapter.value = chapter;
    document.query.verse.value = verse;
    document.query.version.value = version;
    document.query.commtype.value = commtype;
    document.query.submit();
    }

    Problem is that when I start the function. I get the error message "document.openmenu.biblenav is null or not an object"

    Any thoughts would be greatly appreciated.
    Peace out homeskillets!!!

  • #2
    Regular Coder
    Join Date
    Jun 2002
    Posts
    626
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Is this a problem with Netscape 4 version? If it is try this:
    bookindex = document.openmenu.document.biblenav.book_select.selectedIndex

  • #3
    Senior Coder
    Join Date
    Jun 2002
    Location
    near Oswestry
    Posts
    4,508
    Thanks
    0
    Thanked 0 Times in 0 Posts
    in netscape 4, a layer is a document. so a form inside a layer would be

    document.layername.document.formname.element.value

  • #4
    New Coder
    Join Date
    Aug 2002
    Location
    Henderson, NV
    Posts
    21
    Thanks
    0
    Thanked 0 Times in 0 Posts
    I'm actually running into this problem with IE 6, but thanks for the heads up on the Netscape problem. I'll need to address that next 8^D
    Peace out homeskillets!!!

  • #5
    Senior Coder
    Join Date
    Jun 2002
    Location
    Wichita
    Posts
    3,880
    Thanks
    0
    Thanked 0 Times in 0 Posts
    If you're planning to go cross-browser (NS 4+, IE 4+) then you should rework the script a bit anyway:

    Code:
    function start_nav() 
    { 
    var lf=(document.layers) ? document.openmenu.document.biblenav : document.getElementById('biblenav');
    bookindex = lf.book_select.selectedIndex; 
    chapterindex = lf.chapter_select.selectedIndex; 
    versionindex = lf.version_select.selectedIndex; 
    commindex = lf.notes_select.selectedIndex; 
    book = lf.book_select[bookindex].value; 
    chapter = lf.chapter_select[chapterindex].value; 
    verse = 0; 
    version = lf.version_select[versionindex].value; 
    commtype = lf.comm_select[commindex].value; 
    document.query.book.value = book; 
    document.query.chapter.value = chapter; 
    document.query.verse.value = verse; 
    document.query.version.value = version; 
    document.query.commtype.value = commtype; 
    document.query.submit(); 
    }
    The above code actually requires NS 4 or later and IE 5 or later (it doesn't support IE 4 but could easily have IE 4 added) but it should work with the Gecko based browsers like Mozilla 1 and Netscape 6.

    Of course whether the script above works will also depend on what your HTML for this form actually looks like, the problem you're having may be caused by your html not being correct.

  • #6
    New Coder
    Join Date
    Aug 2002
    Location
    Henderson, NV
    Posts
    21
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Thanks, that fixed it. I was just using the wrong syntax to access the elements, you way fixed everything. I also found that in IE you can access the form directly, like through just document.biblenav. But I want it cross browser, so I'm using your method. Thanks!
    Peace out homeskillets!!!


  •  

    Posting Permissions

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