[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

Redirect Forms data to another form for processing

Posted on 2012-08-22
4
Medium Priority
?
815 Views
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">
</FORM>

The new search form is as follows:
<form accept-charset="UTF-8" action="http://search.usa.gov/search" 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" />
</form>

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.
0
Comment
Question by:hcaadev
  • 2
  • 2
4 Comments
 
LVL 54

Accepted Solution

by:
Scott Fell,  EE MVE earned 2000 total points
ID: 38322184
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
<%
response.redirect("http://search.usa.gov/search?"&request.querystring)
%>

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 "http://search.usa.gov/search?"&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="http://search.usa.gov/search" 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" />
</form>

Open in new window

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

Author Comment

by:hcaadev
ID: 38322330
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.
0
 
LVL 54

Expert Comment

by:Scott Fell, EE MVE
ID: 38322366
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.
0
 

Author Closing Comment

by:hcaadev
ID: 38322700
Thanks for the help.  I had a mental block and you steered me in the right direction.
0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Building a website can seem like a daunting task to the uninitiated but it really only requires knowledge of two basic languages: HTML and CSS.
Before we dive into the marketing strategies involved with creating an effective homepage, it’s crucial that EE members know what a homepage is. In essence, a homepage is the introductory, or default page, of a website that typically highlights the …
In this tutorial viewers will learn how to embed videos in a webpage using HTML5. Ensure your DOCTYPE declaration is set to HTML5: "<!DOCTYPE html>": Use the <video> tag to insert a video. Define the src as the URL of your video; this is similar to …
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
Suggested Courses

825 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