Порой надо, чтобы событие кнопки в веб-интерфейсе изменилось, оказывается это очень просто сделать.
element.onclick=function(){myFunction(parametrs);};
Field1:
Field2:
Click the button to copy the content of Field1 to Field2.
А вот исходный код примера:
<script>
someObject = function()
{
this.alme = function(el,postvars)
{
alert(postvars);
el.onclick=function(){myObject.alme(this,document.getElementById('field2').value);};
}
}
myObject = new someObject();
</script>
Field1: <input type="text" id="field1" value="Hello Sky!" />
<br />
Field2: <input type="text" id="field2" value="Bye Ground!" />
<br /><br />
Click the button to copy the content of Field1 to Field2.
<br />
<button onclick="myObject.alme(this,document.getElementById('field1').value)">Show Text</button>