Link to home
Start Free TrialLog in
Avatar of identityless
identityless

asked on

Including external page on JS "onchange"?

I have a drop-down select menu:

<select name="pageID" onchange="insertTemp(this.options[this.selectedIndex].value);">
                                    <option value="form1.php">Form1 template</option>
                                    <option value="form2.php">Form2 template</option>
</select>

<div id="pageInc">Page form goes here</div>


Now, how would I write a JS such that, when someone chooses a value (a page), an external page  gets included?

I have this JS:

function insertTemp(val)
{

var tmpObj = document.getElementById('pageInc');

                  tmpObj.innerHTML = val; //include
}

</script>

I know it might something to do with AJAX, but I am a bit stuck. Can anyone help?
Avatar of BobSiemens
BobSiemens

Don't do tmpObj.innerHTML, use document.load
Avatar of identityless

ASKER

I tried it, but how would I actually include the external page?
ASKER CERTIFIED SOLUTION
Avatar of exoska
exoska

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
sorry for the editor metatag(pspad :) )
and of course you can remove the alert function after you are finished.
You could use an IFRAME for example:
(from http://www.cryer.co.uk/resources/javascript/script4.htm)

    <iframe name="IFrameName"></iframe>

Any html between the <iframe> and </iframe> will be visible if the browser does not support inline frames. The <iframe> takes a number of other parameters, such as:
frameborder       yes or no       Whether the inline frame should have a border.
height       number or percentage       The height of the frame in pixels or as a percentage of the available height.
scrolling       yes, no or auto       Whether scroll bars are provided. The default is auto.
src       file name       The name of the html file to include an display at that point.
width       number or percentage       The width of the frame in pixels or as a percentage of the available width.

It is the 'src' parameter that is of interest here. To change it dynamically either:

    frames['IFrameName'].location.href='http://www.cryer.co.uk/emily'

Note, the alternative:

    document.all.IFrameName.src='www.cryer.co.uk'