I have two pages 1.) form page 2.) I-frame page.

What I am trying to do is: Once the form page is submitted, javascript in the second page would retrieve the values and place them into a an I-frame with a given url.

Example:
=== Page One ===
<form action="page123.html">
<input type="text" name="query">
<input type="submit" value="search">
</form>

=== Page Two ===
Javascript retrieves query values then places them into a iframe.

<iframe src ="/default.asp?client='$query_value' " width="100%"></iframe>

==== End ===

I can not use any server side code!

Thanks in advance.
Diego

Recommended Answers

All 2 Replies

src="/default.asp?client='$query_value'"

I can not use any server side code!

I think you have broken your own rule already since asp is server-side. Anyway, what you probably want to do is look at AJAX.

My first question, was answered and received the following code via Yahoo! Answers.

Pass your form data as a parameter to the second page. Have the second page parse the parameter from the location and apply it generate the src attribute of the iframe.

<html>
<head>
<script type="text/javascript">
function pass() {
var query = document.getElementById( 'query' ).value;
var param = 'client=' + query;
window.location = 'page123.html?' + param;
}
</script>
</head>
<body>
<form>
<input type="text" id="query" />
<input type="button" value="search" onclick="pass()" />
</form>
</body>
</html>


page123.html
<html>
<head>
<script type="text/javascript">
function setIframesSrc() {
var loc = window.location.toString();
var param = loc.substring( loc.indexOf( '?' ) );
var sif = document.getElementById( 'search' );
sif.src = '/default.asp' + param;
}
window.onload = setIframesSrc;
</script>
</head>
<body>
<p>page contents go here</p>
<iframe src="" id="search" style="width:100%"></iframe>
</body>
</html>

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.