php - Html button action only on first click -
i can set action on click html button. need set action on first click. there way this? button radio in form. javascript maybe?
what's important - radio button still might changed. action has done once.
this doesn't work
function myfunction(i){ oform = document.forms["myform"]; if(oform.elements["field"+i].checked) alert("action done earlier"); else action }
the cleanest solution use removeeventlistener to... remove event listener :
var mybutton = document.getelementbyid('someid'); var handler = function(){ // dosomething mybutton.removeeventlistener('click',handler); } mybutton.addeventlistener('click', handler);
(to make cleaner, wrap in iife, in example below)
Comments
Post a Comment