Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    New to the CF scene
    Join Date
    Mar 2010
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Question top webpage search box help

    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

    code:

    <p><iframe src ="http://testsite2.comze.com/test/search" width="100%" height="580" frameBorder="0">
    <p>Your browser does not support iframes.</p>
    </iframe></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!' />
    </center>
    </form>

    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

    Image:


  • #2
    Regular Coder xconspirisist's Avatar
    Join Date
    Jun 2006
    Location
    Great Britain.
    Posts
    138
    Thanks
    1
    Thanked 6 Times in 6 Posts
    You can do it by not using iframes? This is a javascript question, not a PHP one. Here goes;

    Code:
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" 
       "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
    
    <html>
    	<head>
    		<title>192712</title>
    
    		<script type = "text/javascript">
    			function submitThing() {
    				q = document.getElementById('query')
    				iframe = document.getElementById('myiframe');
    
    				iframe.src = 'http://example.com?q=' + q.value;
    			}
    		</script>
    	</head>
    
    <body>
    
    <h1>foo</h1>
    
    <p>
    <input id = "query" />
    <input type = "submit" onclick = "submitThing()" />
    </p>
    
    <p>
    <iframe src = "http://google.com" id = "myiframe">
    <p>Meah</p>
    </iframe>
    </p>
    
    </body>
    </html>
    Demonstration of code available here; http://tydus.net/tst/192712.php
    If I have been helpful, use the "thank" button - It makes me happy!

    xconspirisist.co.uk - homepage of my online alias
    technowax.net - a community for people interested in all forms of modern technology.

  • #3
    New to the CF scene
    Join Date
    Mar 2010
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts
    This is the main site
    http://testsite2.comze.com/test/

    This is the Iframe site
    http://testsite2.comze.com/test/search/

    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.
    Last edited by demonic5150; 03-31-2010 at 02:15 AM.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •