 <p><strong>This avoid's unnecessary assignments of values and variable declarations</strong> </p> <p>1) Focus(param1,param2)</p> <pre><code>function Focus(Locatie,Bonregel) { if (Locatie.value == "" &amp;&amp; Bonregel.value == ""){ Locatie.focus(); } else if (Locatie.value == "") { Locatie.focus } else if (Bonregel.value == "") { Bonregel.focus(); } } </code></pre> <p>2) Send(param1,param2,param3)</p> <pre><code>function Send(keycode, locatie, bonregel) { //Assign value directly document.getElementById("form_keycode").value = keycode; document.getElementById("form_locatie").value=locatie; document.getElementById("form_bonregel").value=bonregel; //submit data from myform document.myform.submit(); } </code></pre> <p>3) Check()</p> <pre><code>function Check() { // check alle data vooor verzenden // Keycode 13 -&gt; ENTER // Keycode 125 -&gt; Green key on device if (event.keyCode == 125) { Send(125, document.getElementById("locatie").value, document.getElementById("bonregel").value); } else if (event.keyCode == 13) { delay(Send(13,document.getElementById("locatie").value,document.getElementById("bonregel").value), "Send", 500); } else { Focus(document.getElementById("locatie"),document.getElementById("bonregel")); } } </code></pre>