milesma
milesma

Reputation: 328

html autocomplete on input text does not work; no history shown

Here is my simple html file, I ran on firefox 47; the autocomplete attribute does not have any effect.

I'm expecting press "down" arrow will show my history. However, it does not work. Why?

Note1: I've checked Firefox | Options | Privacy | Firefox will: Remember History; I've also disabled all add-ins and restarted Firefox; still not work.

Note2: these code are just running on client browser, I don't need a form to submit to server. All I need is to click the button, then retrieve the text from input and do something in JavaScript.

<!DOCTYPE html>
<html>
  <head>
    <meta content="text/html;charset=utf-8" http-equiv="Content-Type">
    <meta content="utf-8" http-equiv="encoding">
    <script type="text/javascript">
      function runCommand(command_str) {

      };
    </script>
  </head>
  <body>
    <input id="command_text" type="text" autocomplete="on" size="80" > 
    <button onclick="runCommand(document.getElementById('command_text').value)">Run Command</button> 
  </body>
</html>

Upvotes: 3

Views: 4401

Answers (1)

Magesh Kumaar
Magesh Kumaar

Reputation: 1467

This happens because you have not wrapped your inputs in a form.

Please wrap it in a form like below and autocomplete attribute to the form too. Also name your parameter.

<form autocomplete="on">
  <input id="command_text" type="text" autocomplete="on" name="command_text" size="80" > 
  <button onclick="runCommand(document.getElementById('command_text').value)">Run Command</button> 
</form>

Upvotes: 3

Related Questions