Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

pass parameter to javascript function onclick

<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>
 
PREVIOUS NEXT
Tagged: #pass #parameter #javascript #function #onclick
ADD COMMENT
Topic
Name
2+1 =