Introduction To Java Script
Introduction To Java Script
About JavaScript
Statements in JavaScript resemble statements in Java, because both languages borrowed heavily from the C language
Notes:
The type attribute is to allow you to use other scripting languages (but JavaScript is the default)
Event Handling
CSS with Java Script
<div style="backgroundcolor:#D94A38;width:170px;height:80px;margin:20px;paddingtop:20px;color:#ffffff;font-weight:bold;font-size:18px;float:left;textalign:center;" onmouseover="this.innerHTML=Non Major Elective'" onmouseout="this.innerHTML='Mouse Over Me'">Offered by University Informatics Centre</div>
Click Event
<!DOCTYPE html> <html> <head> <script> function myfun(id) { id.innerHTML="<b><u><em>Click to draw an underline and make it Italic!</em></u></b>"; } </script> </head> <body> <h1 onclick="myfun(this)">Click to draw an underline and to make it Italic!</h1> </body> </html>
Form Handling
<!DOCTYPE html> <html> <head> <script> function ff() { var x=document.forms["sample"]["sname"].value; if (x==null || x=="") { alert("Student name must be filled out"); return false; } } </script>
<form name="sample" action="uuu.php" onsubmit="return ff()" method="post"> Student name: <input type="text" name="sname"> <input type="submit" value="Submit"> </form>
Q and A