javascript - How to call this function from the other function? -


i have search form idea when user wants search , press enter, pointing search page want.

html

<div class="search">             <form method="post" action="" onsubmit="return do_search();">         <input type="text" value="nhập từ khóa tìm kiếm"                         onfocus="if (this.value == 'nhập từ khóa tìm kiếm') this.value = ''"                         onblur="if (this.value == '')this.value = 'từ khóa'" id="searchinput" name="query" onkeydown="enterkey(event);"/>         <input type="submit" value="" />                                 </form>                     </div><!-- end #search --> 

js

function enterkey(a) {     if(13 == (window.event ? window.event.keycode : a.which)){         var temp = document.getelementbyid("searchinput").value;         alert("enterkey: "+temp);         do_search(temp);    } }  function do_search(a) {      var input = document.getelementbyid("searchinput").value;      alert("do_search "+a);      return  window.location.href = input,!1; } 

the problem when call do_search(temp), alert shows undefined.

why alert not show correct message?

you have error event onsubmit. call function do_search() without parameter. variable a undefined.


Comments

Popular posts from this blog

Magento/PHP - Get phones on all members in a customer group -

php - .htaccess mod_rewrite for dynamic url which has domain names -

Website Login Issue developed in magento -