title: Merge multiple javascript functions into one
body: <p>I have these two javascript functions and wish to "merge" them into one.
  I will be adding a few more of these converting functions later on and would like to keep it simple and cleaner than just duplicating the functions.</p>
  
  <pre><code>&lt;!--Convert kg in pnd--&gt;
  &lt;script type="text/javascript"&gt;
  function init(){
  document.getElementById('kg').onmouseup=function() {
  if(isNaN(this.value)) {
     alert('numbers only!!');
     document.getElementById('kg').value='';
     document.getElementById('pnd').value='';
     return;
   }
     document.getElementById('pnd').value=(this.value*2.2046).toFixed(1);
    }
   }
  if(window.addEventListener){
     window.addEventListener('load',init,false);
   }
  else {
  if(window.attachEvent){
     window.attachEvent('onload',init);
    }
   }
  &lt;/script&gt;
  
  &lt;!--Convert cm in feet--&gt;
  &lt;script type="text/javascript"&gt;
  function start(){
  document.getElementById('hauteur_cm').onmouseup=function() {
  if(isNaN(this.value)) {
     alert('numbers only!!');
     document.getElementById('hauteur_cm').value='';
     document.getElementById('hauteur_pieds').value='';
     return;
   }
     document.getElementById('hauteur_pieds').value=(this.value*0.03280839895).toFixed(1);
    }
   }
  if(window.addEventListener){
     window.addEventListener('load',start,false);
   }
  else {
  if(window.attachEvent){
     window.attachEvent('onload',start);
    }
   }
  &lt;/script&gt;
  </code></pre>
  
  <p>Thanks for the help</p>