Hello,

I'm trying to get some help on a problem I'm having with my iframe and forms.

I have a form that is brought into a hidden iframe. Now I can't seem to get the form to submit? I am guessing this is the case because of how the content in the iframe is brought into the main page. I'm not very good with scripts.

Here is my page:

http://www.mercerhouston.com/index3.html

The form is on the reservations page. This is the form that won't work.

Here is my code:

This is in the stylesheet:

#buffer { position:absolute; visibility:hidden; left:0; top:0 }
div#display { 
margin:0 0 0 0;
    /*margin: 2em 0;*/
    /*border-top: dashed 2px #999;
    border-bottom: dashed 2px #999;*/
    padding-bottom:6px;
    display:none; /* until loaded */
}

This is in the main page (which calls the iframe)

<div id="display"></div>
<!-- onload attribute does not validate but is included here rather than assigned via JavaScript to maximize cross browser support  -->
<iframe id="buffer" name="buffer" src="home.html" onload="dw_displayExternal()"></iframe>

There is also a javascript that is called from the main page to make the whole thing work:

/*************************************************************************
    This code is from dyn-web.com
    free for all uses as long as this notice retained
*************************************************************************/

/*  dw_loader.js      version date: July 2008
    loads url in iframe, transfers body content into div
    provides defaults for iframe and display div ID's 
    also supports use with multiple iframes and divs
    optional message for loading in display div 
    supports functions to be called once the div has been populated with new content 
    function in iframed document can be invoked should some operations need to be performed from there 
*/

function dw_loadExternal(url, ifrmId, divId, bLoadMsg) {
    // defaults for iframe, display div
    ifrmId = ifrmId || 'buffer'; divId = divId || 'display'; 
    if ( window.frames[ifrmId] ) {
        // Could use location.replace method if you do not want back button to load previous iframe url 
        //window.frames[ifrmId].location.replace(url);
        window.frames[ifrmId].location = url;
        // If you want the whole page to scroll to the top when new content is loaded 
        //window.scrollTo(0,0);
        var lyr = document.getElementById? document.getElementById(divId): null;
        if ( lyr && bLoadMsg ) { // Option to display message while retrieving data 
            lyr.innerHTML = '<p>Retrieving data. Please wait ...</p>';
            lyr.style.display = 'block'; 
        }
        return false;
    } 
    return true; // other browsers follow link
}


// called onload of iframe 
// displays body content of iframed doc in div
// checks for and invokes optional functions in both current document and iframed document 
function dw_displayExternal(ifrmId, divId, fp) {
    // defaults for iframe, display div
    ifrmId = ifrmId || 'buffer'; divId = divId || 'display'; 

    var lyr = document.getElementById? document.getElementById(divId): null;
    if ( window.frames[ifrmId] && lyr ) {
        lyr.innerHTML = window.frames[ifrmId].document.body.innerHTML;
        lyr.style.display = 'block'; 

        // when using with script, may have some operations to coordinate
        // function in current doc or iframed doc (doOnIframedLoad)
        if ( typeof fp == 'function' ) {
            fp();
        }

        // Demonstrated in tooltip demo
        if ( typeof window.frames[ifrmId].doOnIframedLoad == 'function' ) {
            window.frames[ifrmId].doOnIframedLoad();
        }
    }
}

thanks for any help!!!!

suggestion: if you want to have autoplay music/video, please offer some way to turn it off. I had to ad block the thing to make it shut up. :D

Actually there is an entire control system in the top right corner to turn it off, turn it down or stop it.

What appen is that all the code within your "loaded" web page is actually not aknowledge.
All the call's to function are redirected to the main page!???

Maybe someone can explain it technicaly?

So if you put all the codes in the main page receiving the loaded Iframe you will be able to use your calls (button and forms)...

The best way do that is to make a reference to your coding from the main page and from the loded page (So it's easier to test)

<script src="mycodes.js" type="text/javascript"></script>

I also notice that the CSS coding will probably not work for the same reason???

So who is up to explain?

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.