Search code examples
textboxclicksubmitenter

click textbox (to enter characters), when submit is clicked


If click the submit button or a-element then automatically the input text is clicked.

function send()
{
    var txt = document.getElementById("textbox");
    txt.click();
}
<input type="text" id="textbox" name="textbox" style="width:90%;">
<a id="send" style="display:none;" onclick="send()" href="">Send</a>


Solution

  • If you want to get the value of "textbox" with the following instruction:

    var txt = document.getElementById("textbox");
    

    Then you need to correct it like this:

    var txt = document.getElementById("textbox").value;