...

View Full Version : how to load pages to iframe using form (client)



tonyappleby36
12-04-2006, 11:31 PM
Hi all,

Can any one tell me how to load up different pages to an inframe using some form. I want to load up page1 or page2 depending on the condition. Sounds simple enough? Here what i have so far: Thanks.

<script type="text/javascript">
<!--

// This is the check script

function checkit()
{

// In textstring I gather the data that are finally written to the textarea.

var textstring = '';
var display_selected = '';
var user_input = '';
for (i=0;i<document.forms[0].uutType.length;i++) {
if (document.forms[0].uutType[i].checked) {
user_input = document.forms[0].uType[i].value;
display_selected = document.displayOptions.displays.options[document.displayOptions.displays.selectedIndex].value
if(document.forms[0].uType[i].value=="B")
{
switch (display_selected)
{
case "NE":
window.location="page1.html"; //<---
break
case "PA":
window.location="page2.html";//<----
break

}//end switch
}//end if checked
}//for
user_input = document.displayOptions.displays.options[document.displayOptions.displays.selectedIndex].value


}
// -->
</script>
<style type="text/css">
td[colspan] {
text-align: center;
}
</style>

</head>
<body>


<form name="displayOptions" action="#" onsubmit="checkit(); return false">
<table class="form">


<tr>

<td>
<input type="radio" name="uType" value="Mxx" />Mxx&nbsp;&nbsp;
<input type="radio" name="uType" value="Bxx" />Bxx&nbsp;&nbsp;



<select name="displays">
<option value='' selected="selected">--- Select ---</option>
<option value="NE">NES</option>
<option value="PA">PAS</option>


</select>&nbsp;&nbsp;
<input type="submit" value="go" />&nbsp;&nbsp;&nbsp;&nbsp;
<input type="reset" /></td></tr>

</table>
</form>

<iframe name="IconFera" style="" frameborder="0" scrolling="no" width="627" marginwidth="0" marginheight="0" height="1088" src="default.htm"></iframe>
</div>

</body>
</html>

mrhoo
12-05-2006, 05:43 AM
Set the src property of the the iframe.

tonyappleby36
12-05-2006, 02:23 PM
what do you mean? Am I not having the src property already (src="default.html") of the iframe?

tonyappleby36
12-05-2006, 02:39 PM
Dont I need a 'target' prop, where target is my iframe name/id? How do I do that with window.location=? Or is there a better way? Thanks

tonyappleby36
12-06-2006, 03:27 PM
never mind , I found my answer:
document.myIframeIDhere.location.href="page1.html"
document.myIframeIDhere.location.href="page2.html" etc..

neel
12-07-2006, 04:55 AM
You Can Do It In Tis Way Also

var get_id = document.getElementById("IFrame_Id");
get_id.src = "page1.html";

//or//

get_id.location.href = "page1.html"



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum