TheGoof
TheGoof

Reputation: 25

Retrieving List from Iframe and updating parent frame with List

I am a noob and attempting to retrieve a HTML list from an Iframe and update a list within the parent frame from the push of a button within the parent frame. Please help, i keep retrieving an error 'UpdateList is not defined', I know i must be doing something wrong, currently feel like banging my head on a wall and plead for assistance

<html> 
<head>
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<style>

<script type="text/Javascript">
function UpdateList(){
var OldList = document.getElementById('Framed');
var Newlist = OldList.contentWindow;
document.getElementById('FileList').innerHTML= Newlist;}


</script>

</style>
</head>
<body style="color:white">
<div id="FileList">
<select>
<option>Push Refresh</option>
</select>
</div>
<iframe NAME="Framed" id="Framed" src="DirectoryPreview.php" width="250" height="100">
</iframe>
<br>
<button onclick="UpdateList()">Push to refresh</button>
</body>

           **Correction for the above, hope it helps others struggling**


<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<style>
</style>
<script type="text/Javascript">
function UpdateList(){
var OldList = document.getElementById('Framed');
var NewList = OldList.contentDocument || iframe.contentWindow.document;
var Contents = NewList.getElementById('List').value;
document.getElementById('FileList').innerHTML= Contents;}
</script>

</head>
<body style="color:Black">
<div id="FileList">
<select>
<option>Push Refresh</option>
</select>
</div>
<iframe NAME="Framed" id="Framed" src="DirectoryPreview.php" width="250" height="100">
</iframe>
<br>
<button onclick="UpdateList()">Push to refresh</button>
</body>
</html>

Upvotes: 2

Views: 340

Answers (1)

perilbrain
perilbrain

Reputation: 8207

Your javascript is embedded inside style tag!!!!How can you ever expect it to execute???

Change it:-

<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<style>
</style> 

<script type="text/Javascript">
function UpdateList(){
var OldList = document.getElementById("Framed");
var Newlist = OldList.contentWindow;
document.getElementById("FileList").innerHTML= Newlist;
}
</script>

Upvotes: 1

Related Questions