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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T04:38:08+00:00 2026-06-04T04:38:08+00:00

Hello friends I have a <input type=text id=tempID /> element in my form I

  • 0

Hello friends I have a <input type="text" id="tempID" /> element in my form

I also have an <input type="button" onclick="doSomething()" /> element in my form.

I want to add the text box value to textbox history when user clicks on the button.

I am processing the request using Jquery ajax. So I have to do it with javascript or Jquery.

Is this possible to add values to the history of particular <input type="text" /> element using javascript/Jquery..??

  • 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-04T04:38:08+00:00Added an answer on June 4, 2026 at 4:38 am

    Here is how you can do it using HTML5 LocalStorage

    $( "#tempID" ).autocomplete({
      source: function( req, resp ) {
    
        var temp = localStorage.getItem('custom_history');  
    
        var data = JSON.parse(temp);
        resp( data );
    
    }
    });
    
    
    $('#tempID').on('blur', function() {
        var temp = localStorage.getItem('custom_history');  
    
        var data = JSON.parse(temp); 
        if($.trim(this.value).length > 0)
           data.push(this.value);
    
        localStorage.setItem('custom_history', JSON.stringify(data)); 
    

    });

    What I am doing is Setting the value into HTML5 Local storage when users moves away from the input field, clicks somewhere else.

    Then retrieving that and setting that as source for jQuery UI auto complete.

    Here is a working fiddle http://jsfiddle.net/joycse06/EBduF/173/

    Enter some value. Click somewhere else. Click back again and add other values. The refresh the fiddle and start typing one of those and auto complete will show up.

    UPDATE

    Based on his comments and later chat the final code he need is this, I am pasting in if it might someone else later

    // if we dont set this line then ff will return null, and null.length will throw an error
    if(!localStorage.getItem('custom_history'))
            localStorage.setItem('custom_history','');
     $( "#test" ).autocomplete({
        source: function( req, resp ) {
          var term = req.term;
          var temp = localStorage.getItem('custom_history');  
            var data = [];
            if(temp.length > 0)
               data = JSON.parse(temp);
           var intRegex = /^\d+$/; 
           data = $.map(data,function(val){
                    if(intRegex.test(val)){
                       if(val.indexOf(term) != -1) 
                            return val;
                       else
                            return null;
                    }
                    else
                        return null;
                 });
          resp( data );
    
        }
    });
    
    
    $('#save').on('click', function() {
        var temp = localStorage.getItem('custom_history'); 
    
          var data = [];
          if(temp.length > 0)
            data = JSON.parse(temp); 
          var value = $.trim($('#test').val());
          if(value.length > 0){
             if($.inArray(value,data) != -1){
                 //alert('Duplicate'); 
                 return;
             }
    
          }
          data.push(value);
          localStorage.setItem('custom_history', JSON.stringify(data)); // set item to localStorage
    });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Hello friends i want to add more effects on my div when i click
Hello friends i have a form view i have handele all needed events successfully
Hello friends I Have a float type variable ,which contains a total price of
Hello my smart friends i have this contact form that i am working on.
Hello Friends check my code http://jsfiddle.net/sUaky/2/ i want to load a web page in
hello friends i want to use toggle on <li> when one <li> is open
hello friends i am having two frames, each frame has a html form which
hello friends i have a check box list which contains all the courses kept
Hello friends I have three div tags on my page.. I am trying to
Hello Friends I am using a list box control in aspx page i have

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.