I have a variable that stores the value of a search box. This value is supposed to represent the id of another element. I want to use the focus command in javascript to focust on the value as an id in the page. how do I do this? This is what I had.
Code:function search(){ var val = document.getElementById('search').value; val.focus(); }
Code:<body id="body" onload="document.getElementById('title').focus();"> <input value=" Search" id="search" onclick="document.getElementById('search').value=' '"></input> <button id="button" onclick="search();">Search</button>


Reply With Quote

Bookmarks