JSFiddle - React, Tailwind, and code Playground
HTML
<div>Form 22</div>
<form name="user_22" action="">
<input name="data1_22" id="data1_22" value="" type="text">
<input name="data2_22" id="data2_22">
<input value="Edit" type="button" name="edit_22" id="edit_22" onclick="editHandle(event);" />
<input value="Other" type="button" name="some_other_action_22" id="some_other_action_22" onclick="otherHandle(event);" />
</form>
<div>Form 24</div>
<form name="user_24" action="">
<input name="data1_24" id="data1_24" value="" type="text">
<input name="Updatedata2_24" id="data2_24">
<input value="Edit" type="button" name="edit_24" id="edit_24" onclick="editHandle(event);" />
<input value="Other" type="button" name="some_other_action_24" id="some_other_action_24" onclick="otherHandle(event);" />
</form>
JavaScript
function getForm(ev)
{
//alert("in");
var ev = ev || window.event;
var formObj = ev.target.form; // find the form from the target element
if (formObj)
{
return formObj;
}
else
{
return false;
}
}
function editHandle(event)
{
var formObj = getForm(event);
alert("form name - "+formObj.name+" - edit action - "+formObj.elements[0].value);
}
function otherHandle(event)
{
var formObj = getForm(event);
alert(formObj);
alert("form name - "+formObj.name+" - other action - "+formObj.elements[0].value);
alert('otherHandle this'+this);
xx();
}
function xx(this)
{
alert('xx this'+this);
}