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 7 of 7
  1. #1
    New to the CF scene
    Join Date
    Jan 2010
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Display form result in iframe on different page

    Hi,
    i will try to be as brief as possible.
    I have a page A with form:

    Code:
    <form id="search" action="find.html"  method="get">
    ... (some select options) ...
    <input type="submit" class="submit" value="search">
    this form look up some holiday destination which appears on this page with url:
    (example)
    Code:
    www.domain.com/find.html?destination=italy&price=500
    Now, I dont want to display result on this page, but on page B, in iframe.
    I found a way how to redirect output as a link to properly show in iframe on page B.

    Page A contains:
    Code:
    <a href="pageb.html?http://www.domain.com/find.html?destination=italy&price=500">show on page B</a><br>
    Page B contains:

    Code:
    <script type="text/javascript">
    <!--
    
    function loadIframe(){
    if (location.search.length > 0){
    url = unescape(location.search.substring(1))
    
    window.frames["iframe"].location=url
    }
    }
    
    onload=loadIframe
    //-->
    </script>
    
    <iframe src="" name="iframe"  id="iframe"</iframe>
    In this case page B will properly load requested link in iframe.
    Problem is it is just a static link...

    I want to display search result from the form.

    Thanks a lot for your help...

  • #2
    Regular Coder
    Join Date
    Jan 2006
    Posts
    568
    Thanks
    6
    Thanked 84 Times in 84 Posts
    It would be better to use a function like the following to get each URL parameter

    Code:
    function gup(name) {
    	name=name.replace(/[\[]/,"\\\[").replace(/[\]]/,"\\\]");
    	var regexS="[\\?&]"+name+"=([^&#]*)";
    	var regex=new RegExp(regexS);
    	var results=regex.exec(window.location.href);
    	if(results==null) return "";
    	else return results[1];
    }
    then set the form method to GET and give each option its own field:

    Code:
    <form action="pageB.html" method="GET">
    	<input name="url" type="text">
    	<input name="destination" type="text">
    	<input name="price" type="text">
    	<input type="submit" value="Submit">
    </form>
    and construct the iframe URL on page B like this

    Code:
    function loadIframe(){
    	if (location.search.length > 0) {
    		var site=gup("url");
    		var dest=gup("destination");
    		var cost=gup("price");
    		var url=site+"?"+"destination="+dest+"&price="+cost;
    		window.frames["iframe"].location=url;
    	}
    }

  • #3
    New to the CF scene
    Join Date
    Jan 2010
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Thanks for your answer gusblake
    It seems like it could work but...
    It should show this address in adress bar to work properly:
    Code:
    http://www.czech-paradise.cz/testb.html?http://www.zajezdy.czech-paradise.cz/hledej.html?zeme=&termin=&cena=&delka=
    (note 2 question marks)

    but it shows this:
    Code:
    http://www.czech-paradise.cz/testb.html?url=http%3A%2F%2Fwww.zajezdy.czech-paradise.cz%2Fhledej.html&zeme=&termin=&cena=&delka=
    which is wrong.

    My code is now, for page A:
    Code:
    <form id="hledej" action="testb.html" method="get">
    <input name="url" type="text" value="http://www.zajezdy.czech-paradise.cz/hledej.html" style="display:none" />
    <select id="zeme" name="zeme">
    ...
    ...
    <input type="submit" class="submit" value="Hledej"/>
    </form>
    Page B:
    Code:
    <body>
    <script type="text/javascript">
    <!--
    function gup(name) {
    	name=name.replace(/[\[]/,"\\\[").replace(/[\]]/,"\\\]");
    	var regexS="[\\?&]"+name+"=([^&#]*)";
    	var regex=new RegExp(regexS);
    	var results=regex.exec(window.location.href);
    	if(results==null) return "";
    	else return results[1];
    }
    function loadIframe(){
    	if (location.search.length > 0) {
    		var site=gup("url");
    		var dest=gup("zeme");
    		var cost=gup("termin");
    		var cost=gup("cena");
    		var cost=gup("delka");
    		var url=site+"?"+"zeme="+zeme+"&termin="+termin+"&cena="+cena+"&delka="+delka;
    		window.frames["fr_zajezdy"].location=url;
    	}
    }
    onload=loadIframe
    //-->
    </script>
    <iframe src="" name="fr_zajezdy" id="fr_zajezdy"> </iframe>
    </body>
    Any idea how to fix it?
    Last edited by ing.kudykam; 01-30-2010 at 10:06 AM.

  • #4
    Regular Coder
    Join Date
    Jan 2006
    Posts
    568
    Thanks
    6
    Thanked 84 Times in 84 Posts
    Each of the variables you use to construct the URL for the iframe need to be assigned by calls to gup:

    Code:
    var site=gup("url");
    var zeme=gup("zeme");
    var termin=gup("termin");
    var cena=gup("cena");
    var delka=gup("delka");
    But if the url (site) will always be the same, you could just do this:

    A:

    Code:
    <form id="hledej" action="testb.html" method="get">
    <select id="zeme" name="zeme">
    ...
    <input type="submit" class="submit" value="Hledej"/>
    </form>
    B:

    Code:
    <body>
    <script type="text/javascript">
    function loadIframe(){
    	if (location.search.length > 0) {
    		window.frames["fr_zajezdy"].location="http://www.zajezdy.czech-paradise.cz/hledej.html"+location.search;
    	}
    }
    
    onload=loadIframe
    </script>
    <iframe src="" name="fr_zajezdy" id="fr_zajezdy"> </iframe>
    </body>

  • #5
    New Coder
    Join Date
    Mar 2008
    Posts
    14
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Exclamation similar question but display on same page.

    I created a book library which im testing and results show up fine in joomla and the included template.

    Now I want to incorporate the search and the results ie the part that says


    into my orgs website.I couldn't install joomla on my work site since they dont support mysql so had to do it externally.

    I managed to get the search box in lib.html which is on work site which is the above link but when it shows the results it opens up my other website in joomla.
    I would rather just show the results in one page and not the other site and without the joomla template on work site.

    any ideas and advice.
    thanks

    see here for result page part


    any advice pls
    Last edited by crosswire; 02-11-2010 at 12:35 AM.

  • #6
    New to the CF scene
    Join Date
    Oct 2011
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    display on same page

    I'm searching for this code or concept that can help me in displaying results of a mini search engine on the same page (into an iframe).

    Did crosswire succeeded finally?

    Anyone?

    Carol

  • #7
    Supreme Master coder! Old Pedant's Avatar
    Join Date
    Feb 2009
    Posts
    25,133
    Thanks
    75
    Thanked 4,338 Times in 4,304 Posts
    Don't hijack old threads.

    Start your own new thread.

    Repost this question in a new thread but give more details. Such as what language/system the mini search engine is written in (that is, is it PHP? Or is it all HTML/Javascript?).

    Also, your question is much much simpler than the one in this thread. It's trivial to work with iframes in the same window/page. This thread was about working with iframes in another window.
    An optimist sees the glass as half full.
    A pessimist sees the glass as half empty.
    A realist drinks it no matter how much there is.


  •  

    Posting Permissions

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