View Full Version : top webpage search box help

03-31-2010, 12:30 AM
:thumbsup: all files are php .... Website with the search box in the main site and the search engine is in iframe

This is the code for the top of the website search box

<input name="search" class="search" type="text" value="under construction..." onfocus="if(this.value == 'under construction...'){this.value = '';}"/>

The search engine is on the website in iframe


<p><iframe src ="http://testsite2.comze.com/test/search" width="100%" height="580" frameBorder="0">
<p>Your browser does not support iframes.</p>

The form code in the search/index.php for the iframe

<form action='index.php' method='get'>
<center><h2>Search</h2><br />

<input type='text' name='query' size='50' value='<?php echo $query; ?>' />
<br />
<input type='submit' value='Search!' />

How can i get to where someone types in the top search box and the results show in the results page from the search engine in iframe



03-31-2010, 12:40 AM
You can do it by not using iframes? :) This is a javascript question, not a PHP one. Here goes;

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"


<script type = "text/javascript">
function submitThing() {
q = document.getElementById('query')
iframe = document.getElementById('myiframe');

iframe.src = 'http://example.com?q=' + q.value;



<input id = "query" />
<input type = "submit" onclick = "submitThing()" />

<iframe src = "http://google.com" id = "myiframe">


Demonstration of code available here; http://tydus.net/tst/192712.php

03-31-2010, 02:12 AM
This is the main site

This is the Iframe site

If u click on Business Directory u'll see the Iframe site in the middle of the main site so how can i use ur code ... to different sites but trying to get the top serach box after submit show up in the iframe search page ... and if you type in "ho" in the search u'll get hollywood as the result from the iframe site. and the search box from the main site u get nothing to the iframe site.