Forum Moderators: open

Message Too Old, No Replies

Problem Changing Source of Frame

Object Expected

         

theriddla1019

2:51 pm on Sep 15, 2004 (gmt 0)

10+ Year Member



Im Not sure what the problem is, im pretty sure my code is correct. Anyone see any problems?

<html>
<head>
<script language="Javascript">

function AlterAction(value, id){
document.all.votypeframe.src=value + ".php?epid=" + id;
}

</script>
</head>
<body bgcolor="#addfff">
<form name="vorder" method="post" action="">
<table>
<tr>
<td>
<center><h3>Verbal Order Type:</h3></center>
</td>
</tr>
<tr>
<td>
<center><h4>Request Lab/Lab Results</h4></center>
<script> AlterAction("viewlab", 64); </script>
</td>
</tr>
<tr>
<td>

<IFRAME NAME="votypeframe" SRC="lightblueblank.php" WIDTH="732" HEIGHT="300" align="center" FRAMEBORDER="0" SCROLLING="NO" NORESIZE></IFRAME>
</td>
</tr>
</table>
</form>
</body>
</html>

It gives me an object expected error and does not reload the iframe with the new href...also tried "votypeframe.location.href="etcetcetc"" and that didnt work either. Any ideas?
Thanx,
Adam

Bernard Marx

3:12 pm on Sep 15, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



It's because you are trying to reference an element that hasn't yet loaded
- it's below the (immediately executed) JS statement in the source code.

..and you shouldn't be using document.all either (IE-only)

Either put that script block below the iframe in the source,
or execute the statement after load (this can go in the head):

[pre]

function AlterAction(value, id){
document.getElementById("votypeframe").src=value + ".php?epid=" + id;
// to replace page in history,
// (only if frame is within domain)
// document.frames.votypeframe.location.replace(value+".php?epid"+id);
}

window.onload = function(){ AlterAction("viewlab", 64); }
[/pre]

theriddla1019

3:52 pm on Sep 15, 2004 (gmt 0)

10+ Year Member



Logic Error...*bonks head*
Thanx :)