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

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
switch (display_selected)
case "NE":
window.location="page1.html"; //<---
case "PA":

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

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


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


<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>

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


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


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

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

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

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

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";


get_id.location.href = "page1.html"

EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum