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.
Page 1 of 2 12 LastLast
Results 1 to 15 of 19
  1. #1
    New Coder
    Join Date
    Sep 2011
    Posts
    20
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Search function from external source to show results on our site

    I work for a promotional products company and we use a database called Sage which brings together all products from all different companies into one easy-to-use search function.

    They supplied us our own "online storefront" which visually sucks. So I decided to try and use their search function on our main website.

    I viewed their source and took what I needed to make the search functional on our website. This is the code:

    Code:
    <form method="GET" action="http://www.promoplace.com/ws/ws.dll/StartSrch" onsubmit="return Form_Validator(SrchCrit)" name="SrchCrit">
        <input type="hidden" name="DistID" value="27738">
        <input type="hidden" name="ProdSelect" value="">
        <input type="hidden" name="Srching" value="1">
        <input type="hidden" name="CatName" value="">
        <input id="search-button" type="submit" value="" alt="Start Search!" onMouseOver="window.status='Start your search';return true" onMouseOut="window.status='';return true;">
        <input type="text" id="search-field" name="keywords">
        <input type="hidden" name="GlobalSearch" value="">
    </form>
    What I would like to do is have the results open on one of our website's pages... with our header, links, etc. even if the solution is a blank page with an iFrame and the results loaded inside of it.

    Is there a way to go about this?

    Thank you in advance for any help.

  • #2
    Regular Coder stevenmw's Avatar
    Join Date
    Jun 2007
    Location
    OK
    Posts
    497
    Thanks
    27
    Thanked 31 Times in 31 Posts
    Just code the form to use a seperate php page to process the search and display it. Make sure to design the page with the iframe, and whatever else you want. The display the results using a while loop where ever in the page you want.

    This is border line web projects category material.

  • #3
    New Coder
    Join Date
    Sep 2011
    Posts
    20
    Thanks
    1
    Thanked 0 Times in 0 Posts
    Thank you for the reply and I apologize if this should be in another category.

    Quote Originally Posted by stevenmw View Post
    The display the results using a while loop where ever in the page you want.
    Could you give me an example of this part? I don't know much about it. I would appreciate it very much.

  • #4
    New Coder
    Join Date
    Sep 2011
    Posts
    20
    Thanks
    1
    Thanked 0 Times in 0 Posts
    I am still trying to figure out this issue. If anyone has any other suggestions or can write me up an example, that would be an enormous help.

  • #5
    Senior Coder
    Join Date
    Apr 2011
    Location
    London, England
    Posts
    2,120
    Thanks
    15
    Thanked 354 Times in 353 Posts
    This is just a rough draft but:

    Re-direct the form submission to your own page, which contains an iframe that will display the search results;
    Your new page will contain all your headers, links, etc., plus the iframe, and code to process the search data - that is, to obtain the results from promoplace.com and display them in the iframe.

    Code:
    <!-- pagea.html -->
    <form method="GET" action="pageb.html" onsubmit="return Form_Validator(SrchCrit)" name="SrchCrit">
        <input type="hidden" name="DistID" value="27738">
        <input type="hidden" name="ProdSelect" value="">
        <input type="hidden" name="Srching" value="1">
        <input type="hidden" name="CatName" value="">
        <input id="search-button" type="submit" value="" alt="Start Search!" onMouseOver="window.status='Start your search';return true" onMouseOut="window.status='';return true;">
        <input type="text" id="search-field" name="keywords">
        <input type="hidden" name="GlobalSearch" value="">
    </form>
    Code:
    <!DOCTYPE html><!-- pageb.html -->
    <html> 
    <head> 
    <title>Document Title</title> 
    <script type="text/javascript"> 
    function loadIframe() { 
        if (location.search.length > 0) { 
            searchargs = decodeURIComponent(location.search.substring(1));
            document.getElementById("myiframe").src = "http://www.promoplace.com/ws/ws.dll/StartSrch?" +
                encodeURIComponent(searchargs);
        } else {
            document.getElementById("myiframe").src = "defaultpage.html";
        }
    } 
    window.onload=loadIframe;  
    </script>
    
    </head>
    
    <body> 
        <iframe name="myiframe" id="myiframe" src=""></iframe> 
    </body> 
    </html>
    "I'm here to save your life. But if I'm going to do that, I'll need total uninanonynymity." Me Myself & Irene.
    Validate your HTML and CSS

  • #6
    New Coder
    Join Date
    Sep 2011
    Posts
    20
    Thanks
    1
    Thanked 0 Times in 0 Posts
    Thank you very much for the reply, AndrewGSW.

    I did everything you said but its giving me an error when i submit the search. The error comes from SAGE (who runs promoplace) saying that the address is missing. I think it has something to do with
    Code:
    document.getElementById("myiframe").src = "http://www.promoplace.com/ws/ws.dll/StartSrch?" +
    If you go to our "behind the scenes" site, youll see two search bars. The top one is the original one I had which opened the results in its own page, no headers etc. The second is using your code. Maybe you can find something between the two that helps.

  • #7
    Senior Coder
    Join Date
    Apr 2011
    Location
    London, England
    Posts
    2,120
    Thanks
    15
    Thanked 354 Times in 353 Posts
    You can't have two forms of the the same name on the same page. The data that is being passed is probably largely taken from the first form.

    Delete the first form temporarily.
    "I'm here to save your life. But if I'm going to do that, I'll need total uninanonynymity." Me Myself & Irene.
    Validate your HTML and CSS

  • #8
    New Coder
    Join Date
    Sep 2011
    Posts
    20
    Thanks
    1
    Thanked 0 Times in 0 Posts
    Ok, removed but no change.

  • #9
    Senior Coder
    Join Date
    Apr 2011
    Location
    London, England
    Posts
    2,120
    Thanks
    15
    Thanked 354 Times in 353 Posts
    Quote Originally Posted by pruocco View Post
    Ok, removed but no change.
    I copied the form details from your original post. Did some of those hidden fields have values that you removed from the code that you posted? I'm assuming they all (possibly) require values.
    "I'm here to save your life. But if I'm going to do that, I'll need total uninanonynymity." Me Myself & Irene.
    Validate your HTML and CSS

  • #10
    Regular Coder
    Join Date
    Jul 2012
    Location
    London
    Posts
    473
    Thanks
    4
    Thanked 86 Times in 86 Posts

  • #11
    New Coder
    Join Date
    Sep 2011
    Posts
    20
    Thanks
    1
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by AndrewGSW View Post
    I copied the form details from your original post. Did some of those hidden fields have values that you removed from the code that you posted? I'm assuming they all (possibly) require values.
    No, those values were like that when I copy/pasted the code.

    This is the page I copied the code from. http://www.promoplace.com/ws/ws.dll?DistID=27738
    27738 being our customer ID.
    Last edited by pruocco; 08-14-2012 at 02:46 PM.

  • #12
    New Coder
    Join Date
    Sep 2011
    Posts
    20
    Thanks
    1
    Thanked 0 Times in 0 Posts
    Nope, i did not change any values. Simply copy pasted the form and took out the fields i didnt want to use (ie category, theme, etc.) leaving just the keyword field and the submit button.

  • #13
    Senior Coder
    Join Date
    Apr 2011
    Location
    London, England
    Posts
    2,120
    Thanks
    15
    Thanked 354 Times in 353 Posts
    Sorry, but the address you entered is not valid. (SAGE WebStore ERR:Missing or invalid ID)
    That error message is coming from SAGE. The info being passed to the iframe is:

    Code:
    DistID=27738&ProdSelect=&Srching=1&CatName=&keywords=asearchterm&GlobalSearch=
    so there seems to be something missing from these terms that SAGE requires. But the message seems quite specific in requiring a (correct) ID.

    Code:
    <form method="GET" action="results.php" onsubmit="return Form_Validator(SrchCrit)" name="SrchCrit">
    I think you should include the function Form_Validator() on the first page, even if it just does 'return true'. Alternatively, remove this part: onsubmit="..." temporarily.
    "I'm here to save your life. But if I'm going to do that, I'll need total uninanonynymity." Me Myself & Irene.
    Validate your HTML and CSS

  • #14
    New Coder
    Join Date
    Sep 2011
    Posts
    20
    Thanks
    1
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by AndrewGSW View Post
    I think you should include the function Form_Validator() on the first page, even if it just does 'return true'. Alternatively, remove this part: onsubmit="..." temporarily.
    I'm a noob with JavaScript, I'm not sure how to do this correctly. I removed the onsubmit="..." but no change. The ID is correct, I just verified it with my boss.

    It's weird though - the search worked fine when it was on it's own page, no iFrame. Now it doesn't work, but nothing was changed or added except the javascript and iFrame itself. I would assume that there is something going wrong during the redirection to the iFrame, but I really have no idea. Just a guess.

    Please dont give up on me, lol.

  • #15
    Senior Coder
    Join Date
    Apr 2011
    Location
    London, England
    Posts
    2,120
    Thanks
    15
    Thanked 354 Times in 353 Posts
    if (location.search.length > 0) {
    searchargs = decodeURIComponent(location.search.substring(1));
    document.getElementById("myiframe").src = "http://www.promoplace.com/ws/ws.dll/StartSrch?" +
    encodeURIComponent(searchargs);
    } else {
    document.getElementById("myiframe").src = "defaultpage.html";
    }

    Try deleting the word encodeURIComponent. If not, try also deleting decodeURIComponent. I suspect it's the encoding..
    "I'm here to save your life. But if I'm going to do that, I'll need total uninanonynymity." Me Myself & Irene.
    Validate your HTML and CSS


  •  
    Page 1 of 2 12 LastLast

    Posting Permissions

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