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

  • Home
  • SEARCH
  • 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 6967207
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T16:17:28+00:00 2026-05-27T16:17:28+00:00

Let’s say I’m on a page on my website: http://www.example.com/SearchResults.asp?Search=stackoverflow . Is it possible

  • 0

Let’s say I’m on a page on my website: http://www.example.com/SearchResults.asp?Search=stackoverflow. Is it possible to use a JavaScript or jQuery code to get the variable “search” from the URL string and populate it into the value of the search box?

Basically I’ll have my regular identified search box:

<input type="text" title="Search" id="search_box" />

And a user will search for something, but I will want a JavaScript or jQuery code that will get the value from the “search” variable in the URL string when the customer is on the Search.asp page and add it as the “value” to the input#search.

So the user will be on this page: http://www.example.com/SearchResults.asp?Search=stackoverflow and the search box will look like:

<input type="text" title="Search" id="search_box" value="stackoverflow" />

Thanks

  • 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-27T16:17:28+00:00Added an answer on May 27, 2026 at 4:17 pm

    You could try this function:

    function getSearchVariable(variable) 
    {
        var query = window.location.search.substring(1);
        var vars = query.split("&");
        for (var i=0;i<vars.length;i++) {
            var pair = vars[i].split("=");
            if(pair[0] == variable){
                return unescape(pair[1]);
            }else{
                return false;
            }
        }
    }
    

    If this function is present in the sample you mentioned above, all you would call getSearchVariable(“Search”) to have “stackoverflow” returned.

    So in your page, you would have a script element that looks like:

    <script type="text/javascript">
        function getSearchVariable(variable) 
        {
            var query = window.location.search.substring(1);
            var vars = query.split("&");
            for (var i=0;i<vars.length;i++) {
                var pair = vars[i].split("=");
                if(pair[0] == variable){
                    return unescape(pair[1]).split("+").join(" ");
                }else{
                    return "";
                }
            }
        }
    
        $(document).ready(function(){
            $("#search_box").val(getSearchVariable("Search"));
        });
    </script>
    

    Hope that helps!

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Let's say I have a dataset in an ASP.NET website (.NET 3.5) with 5
Let's say I query for http://images.google.com.sg/images?q=sky&imgcolor=black and I get all the black color sky,
Let's say I have a wav file at a url: http://hostname.com/mysound.wav I'm trying to
Let's say i go to myblog.com/post/12 . The /post handler is already defined, but
Let's say I have some content classes like Page, TabGroup, Tab, etc. Certain of
Let's say I have a main folder in my website named test which contains
Let's say for example i have URL containing the following percent encoded character :
Let's say I create and execute a System.Net.FtpWebRequest . I can use catch (WebException
Let's say you have a page that produces text/plain output. If you set the
Let's say you create a wizard in an HTML form. One button goes back,

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.