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 7940119
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T23:17:37+00:00 2026-06-03T23:17:37+00:00

I have this code var file = getUrlVars()[file]; if(file){ document.getElementById(‘search’).value = file; } function

  • 0

I have this code

var file = getUrlVars()["file"];
    if(file){
            document.getElementById('search').value = file; 
    }
    function getUrlVars() {
    var vars = {};
    var parts = window.location.href.replace(/[?&]+([^=&]+)=([^&]*)/gi, function(m,key,value) {
        vars[key] = value;
    });
    return vars;
}

It reads the parameter file from url and then puts the value in the search field.
The search field is ajax powered, when a user enters a letter it starts searching and outputs results.
The problem is that when the scripts puts the value in the search field nothing happens, how do i make the search to fire up?

This is my search field

<input type="text" id="search" class='search_input' />

UPDATE:
My Ajax search code is this

// Search
$(document).ready(function()
    {
        $(".search_input").focus();
        $(".search_input").keyup(function() 
    { 
    var search_input = $(this).val();
    var keyword= encodeURIComponent(search_input); 
    var yt_url='http://domain.com/search.php?q='+keyword;  
    $.ajax({
        type: "GET",
        url: yt_url,

        success: function(response)
    {
        $("#result").html('');
        if(response.length)
        { 
            $("#result").append(response); 
        }
        else
        {
            $("#result").html("<div id='no'>No results</div>");
        }
    }   

    }); 
    });
}   ); 
  • 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-06-03T23:17:39+00:00Added an answer on June 3, 2026 at 11:17 pm

    Your search will only “fire” if the event that initilizes the AJAX functionality is triggered. Thus, you need to trigger the event. My wild guess is the event is bound to either:

     - keyup
     - click
     - blur
    

    You haven’t posted the relevant code, but that should be enough of an answer…


    After your update

    A quick solution is to initiate the keyup event on the search field:

    $(".search_input").keyup(function() { ... }).keyup();
    

    Or, you could re-factor the code:

    function searchlogic() { ... };
    
    $(".search_input").keyup(searchlogic);
    
    searchlogic();
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have progress.js file which has the following code $('#text_area_input').keyup(function() { var text_area_box =$(this).val();//Get
I have this code in a js file: function buildRolePicker() { var pnl =
If I have this code in a file called custom.js: var kennel = function(){this._init();};
I have this ajax jquery code: var form = document.getElementById('frm'); var data_string = form.serialize();
I have this code right now : $(document).ready(function() { var ktitle = $('.hiddentwo').text(); $('div#tab2').load('morefour.php?title=ktitle');
I have this code snippet in .js file $(function () { // KeyDates var
I have this code: var fullpath = $(this)[0].src; var a = document.createElement('a'); a.href =
Imagine I have this code: var myFunc1 = function(event) { alert(1); } var myFunc2
I have this code that loads an xml file using javascript: function getXmlDocument(sFile) {
I have this javascript code: var img = document.createElement(img); img.setAttribute('src', 'close.png'); img.setAttribute('alt', 'cancel this

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.