xxxxxxxxxx
<input type="button" value="mybutton1" onclick="dosomething(this)">
function dosomething(element){
alert("value is "+element.value); //you can print any value like id,class,value,innerHTML etc.
};
xxxxxxxxxx
<button onclick="myfunctionName('John')">Click</button>
<script type="text/javascript">
function myfunctionName(String){
alert(String);
}
</script>
<!-- Will Show an Alert Box Saying "John" -->
xxxxxxxxxx
<input type="text" id="dt" value="" required oninvalid="setCustomValidity('Please enter e value to process!!')" oninput="setCustomValidity('')" >
<input type='button' value="Save" onclick="processRequest(document.getElementById('dt').value)">
<script>
window.onload=(()=>{document.querySelector("input[id='dt']").value=(new Date()).getFullYear();});
processRequest=((val)=>{
alert(val);
});
</script>
xxxxxxxxxx
<button onclick="myfunctionName('John')">Click</button>
<script type="text/javascript">
function myfunctionName(String){
alert(String);
}
</script>