Pass variables to a function, and use these variable values in the function : Function « Language Basics « JavaScript DHTML
- JavaScript DHTML
- Language Basics
- Function
Pass variables to a function, and use these variable values in the function
<html>
<head>
<script type="text/javascript">
function myfunction(txt){
alert(txt)
}
</script>
</head>
<body>
<form>
<input type="button" onclick="myfunction('Java!')" value="Java">
<input type="button" onclick="myfunction('Java too!')" value="Java too">
</form>
</body>
</html>
Related examples in the same category