JSFiddle - React, Tailwind, and code Playground
by Akram kamal
HTML
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title></title>
</head>
<body>
<form action="" method="post" name="form1" onsubmit="return false;">
<input type="hidden" name="val" id="val1" value="a" />
<input type="hidden" name="anotherval" id="anotherval1" value="b" />
<input type="submit" name="SavePlantInfo" class="do_submit" id="save_opt1" value="Save" />
<input type="submit" name="SavePlantInfoAndEmail" class="do_submit" id="save_email_opt1" value="Save And Email" />
</form>
<form action="" method="post" name="form2" onsubmit="return false;">
<input type="hidden" name="val" id="val2" value="a" />
<input type="hidden" name="anotherval" id="anotherval2" value="b" />
<input type="submit" name="Save" class="do_submit" id="save_opt2" value="Save" />
<input type="submit" name="SaveAndEmail" class="do_submit" id="save_email_opt2" value="Save And Email" />
</form>
</body>
</html>
JavaScript
$(document).ready(function() {
$(".do_submit").click(function() {
var element = $(this);
var Id = element.attr("id");
var val = $("#val" + Id).val();
var anotherval = $("#anotherval" + Id).val();
alert("Name: " + $(this).attr("name"));
});
});