<input type="button" value="Cick Me" onclick="show()">
<script>
function show(){
alert("This is a test");
}
</script>
Here as you see I used <script> means it default treated as <script language="javascript">
Lest See another example..
<html>
<head>
<title>JavaScript Example</title>
</head>
<body>
<table>
<tr><td>Please Enter Your Name:</td><td><input type="text" id="name"></td></tr>
<tr><td> </td><td><input type="button" onClick="test()" value="Click on Me."></td></tr>
</table>
</body>
<script language="javascript">
function test()
{
var name=document.getElementById('name').value;
alert("Welcome"+name);
}
</script>
</html>
<script>
function show(){
alert("This is a test");
}
</script>
Here as you see I used <script> means it default treated as <script language="javascript">
Lest See another example..
<html>
<head>
<title>JavaScript Example</title>
</head>
<body>
<table>
<tr><td>Please Enter Your Name:</td><td><input type="text" id="name"></td></tr>
<tr><td> </td><td><input type="button" onClick="test()" value="Click on Me."></td></tr>
</table>
</body>
<script language="javascript">
function test()
{
var name=document.getElementById('name').value;
alert("Welcome"+name);
}
</script>
</html>
No comments:
Post a Comment