identityless
asked on
Including external page on JS "onchange"?
I have a drop-down select menu:
<select name="pageID" onchange="insertTemp(this. options[th is.selecte dIndex].va lue);">
<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('p ageInc');
tmpObj.innerHTML = val; //include
}
</script>
I know it might something to do with AJAX, but I am a bit stuck. Can anyone help?
<select name="pageID" onchange="insertTemp(this.
<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('p
tmpObj.innerHTML = val; //include
}
</script>
I know it might something to do with AJAX, but I am a bit stuck. Can anyone help?
Don't do tmpObj.innerHTML, use document.load
ASKER
I tried it, but how would I actually include the external page?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
sorry for the editor metatag(pspad :) )
and of course you can remove the alert function after you are finished.
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'].locat ion.href=' http://www.cryer.co.uk/emily'
Note, the alternative:
document.all.IFrameName.sr c='www.cryer.co.uk'
(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'].locat
Note, the alternative:
document.all.IFrameName.sr