Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6322599
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T16:21:43+00:00 2026-05-24T16:21:43+00:00

I am trying to redirect to google search on simple form submit but it

  • 0

I am trying to redirect to google search on simple form submit but it won’t work. Here is my code stripped:

<script type="text/javascript">
function search(){
alert("in function!");
var a = document.getElementById("searchbox").value;
a = "http://www.google.com/#q=" + a;
a = a.replace(" ","+");
alert(a);
document.location = a;
}

</script>

<form method="post" action="#" onSubmit="search()">

<input type="text" id="searchbox" />

</form>

I get no alerts at all.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-24T16:21:44+00:00Added an answer on May 24, 2026 at 4:21 pm

    Two things, first it works fine for me, http://jsfiddle.net/LzwAt/1/
    Make sure you have the javascript in the head tag of the file, and don’t forget the submit button ;).

    Also, if you just want to submit to google you could always just do:

    <form action="http://google.com/search" method="GET">
        <input type="text" name="q" />
        <input type="submit" name="go" value="Search">
    </form>
    

    EDIT:
    try this:

    <html>
        <head>
            <script type="text/javascript">
                function search()
                {
                    alert("in function!");
                    var a = document.getElementById("searchbox").value;
                    a = "http://www.google.com/#q=" + a;
                    a = a.replace(" ","+");
                    alert(a);
                    document.location = a;
                }
            </script>
        </head>
        <body>
            <form method="post" action="#" onSubmit="search();return false;">
                <input type="text" id="searchbox" />
                <input type="submit" name="submit" value="submit">
            </form>
        </body>
    </html>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to redirect a page via JavaScript: window.location('http://www.google.com'); but in firefox, I'm getting
I'm trying to run some java script just before a page redirect but it
I have a custom registration form. I am trying to redirect users to a
I've been trying everything to manage a redirect from www.domain.com to domain.com, but nothing
I'm trying to rewrite URLs to a generic show_page.php script, but I'm having trouble
I am trying to redirect users of value of a localstorage key but it
I'm trying to parse this HTML block: <div class=v120WrapperInner><a href=/redirect?q=http%3A%2F%2Fwww.google.com%2Faclk%3Fsa%3DL%26ai%3DCKJh--O7tSsCVIKeyoQTwiYmRA5SnrIsB1szYhg2d2J_EAhABIJ7rxQ4oA1CLk676B2DJntmGyKOQGcgBAaoEFk_Qyu5ipY7edN5ETLuchKUCHbY4SA#0%26num%3D1%26sig%3DAGiWqtwtAf8NslosN7AuHb7qC7RviHVg7A%26q%3Dhttp%3A%2F%2Fwww.youtube.com%2Fwatch%253Fv%253D91sYT_8CN8Q%2526feature%253Dpyv%2526ad%253D3409309746%2526kw%253Dsusan%25252#0boyle&amp;adtype=pyv&amp;event=ad&amp;usg=bR7ErKA_3szWtQMGe2lt1dpxzHc= title=The Valley Downs Chicago><img
I am trying to use SecuritySwitch (http://code.google.com/p/securityswitch/) on an asp.net website. On secure pages
I'm trying to figure out how to redirect output from some FORTRAN code for
I'm trying to make a backup but it won't: 2011-10-01 09:22:43.706 /remote_api 302 5ms

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.