Redirect Forms data to another form for processing

Posted on 2012-08-22
Last Modified: 2012-08-22
Hi All,

I have a little problem I am having issues resolving.  We have a search engine on our website.  The search is on every page of our website.  This search uses a form and passes the form data to a .asp page for processing.  We have now introduced a new search feature on the site that uses completely different code

<FORM name="formSear" action="/search/index.asp" method="GET">
<INPUT name="Send" type="submit" value="search" class="search_button">
<INPUT name="searWords" type="text" value="" alt="enter search text here">

The new search form is as follows:
<form accept-charset="UTF-8" action="" id="search_form" method="get">
<input name="commit" type="submit" value="Search"  class="search_button"/>
<input autocomplete="off" class="usagov-search-autocomplete" id="query" name="query" type="text" />

So basically what I want to do and not do.

I do not want to go to EVERY page of my site and change the form
Find a way to take the "searWords" form item and pass it to the new form and automatically submit that form.

My guess is:

I can grab the form value for "searWords" and create a variable.
I can input that new variable into the new form under the "query" form item

The above is easy but I do not understand how I can automatically submit that new form to where it is seamless to the user.  The old forms action is  "/search/index.asp" so this is where I will place the code but again, I do not know how to automatically submit the new form.

Thank you for your time.
Question by:hcaadev
    LVL 52

    Accepted Solution

    Since the site is using a get meaning it goes to the querysting, you could simply add a redirect code to the old page.

    On search/index.asp at very top

    Open in new window

    I wonder if it would be better to handle it as a 301 redirect

    Response.Status="301 Moved Permanently"
    Response.AddHeader ""&request.querystring

    Open in new window

    Of course after doing that quick fix... I would get an intern to replace the code using an include file.  So the form is loaded from

       <!--#include virtual="/somefolder/searchpage.asp"-->
    And inside of that searchpage.asp is
    <form accept-charset="UTF-8" action="" id="search_form" method="get">
    <input name="commit" type="submit" value="Search"  class="search_button"/>
    <input autocomplete="off" class="usagov-search-autocomplete" id="query" name="query" type="text" />

    Open in new window

    Now next time you need to change this code, you just upload the one include file.

    Author Comment

    Intern!???  I wish!  :-)  

    Yes an include file would be preferable.  We started using include files a while ago due to this type of issue.  We are in the middle of a redesign so we will be using more includes.  Besides that, I will test what you suggested.  I completely forgot about the response.redirect.

    I will let you know.  Testing before I leave for the day.
    LVL 52

    Expert Comment

    by:Scott Fell, EE MVE
    Sounds good. Given the choice, I think it may be better to use the 301 redirect version.  Then if google/bing/yahoo have a search with a query string indexed, it will eventually go to the new page.  If you are concerned with seo you are ok with one bounce but if it is part of redirect from another redirect you loose the juice so I think the 301 version is better.

    Author Closing Comment

    Thanks for the help.  I had a mental block and you steered me in the right direction.

    Featured Post

    Maximize Your Threat Intelligence Reporting

    Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

    Join & Write a Comment

    Introduction HTML checkboxes provide the perfect way for a web developer to receive client input when the client's options might be none, one or many.  But the PHP code for processing the checkboxes can be confusing at first.  What if a checkbox is…
    Use these top 10 tips to master the art of email signature design. Create an email signature design that will easily wow recipients, promote your brand and highlight your professionalism.
    The viewer will receive an overview of the basics of CSS showing inline styles. In the head tags set up your style tags: (CODE) Reference the nav tag and set your properties.: (CODE) Set the reference for the UL element and styles for it to ensu…
    HTML5 has deprecated a few of the older ways of showing media as well as offering up a new way to create games and animations. Audio, video, and canvas are just a few of the adjustments made between XHTML and HTML5. As we learned in our last micr…

    755 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    19 Experts available now in Live!

    Get 1:1 Help Now