Download presentation
Presentation is loading. Please wait.
Published byPearl Henry Modified over 8 years ago
1
JAVA SCRIPT HOW TO PROGRAM DR. JOHN ABRAHAM PROFESSOR UTPA SOME SLIDES FROM W3SCHOOLS
2
SCRIPT IN BODY OF HTML document.write("Hello World!");
3
FUNCTIONS IN THE HEADING function message() { alert("This alert box was called with the onload event"); } SEE NEXT SLIDE FOR RUN
4
PROGRAM RUN
5
Scripts in the head section: Scripts to be executed when they are called, or when an event is triggered, go in the head section. When you place a script in the head section, you will ensure that the script is loaded before anyone uses it.
6
Scripts in the body section: Scripts to be executed when the page loads go in the body section. When you place a script in the body section it generates the content of the page.
7
Using an External JavaScript Sometimes you might want to run the same JavaScript on several pages, without having to write the same script on every page. To simplify this, you can write a JavaScript in an external file. Save the external JavaScript file with a.js file extension.
8
Here is whole program that might help you with the assignment. Currency var rem, amt100, amt20, amt10, amt5, amt1, amt025, amt010, amt005, amt001; function convert_Currency() { var amt; amt = MyForm1.amount.value; amt100 = Math.floor(amt / 100); rem = amt % 100; amt20 = Math.floor(rem / 20); rem = rem % 20; amt10 = Math.floor(rem / 10); rem = rem % 10; amt5 = Math.floor(rem / 5); rem = rem % 5; amt1 = Math.floor(rem / 1); rem = rem % 1; amt025 = Math.floor(rem /.25); rem = rem %.25; amt010 = Math.floor(rem /.10); rem = rem %.10; amt005 = Math.floor(rem /.05); rem = rem %.05; amt001 = Math.floor(rem /.01); } function display_Currency() { convert_Currency(); MyForm1.amt100Frm.value = amt100; MyForm1.amt20Frm.value = amt20; MyForm1.amt10Frm.value = amt10; MyForm1.amt5Frm.value = amt5; MyForm1.amt1Frm.value = amt1; MyForm1.amt025Frm.value = amt025; MyForm1.amt010Frm.value = amt010; MyForm1.amt005Frm.value = amt005; MyForm1.amt001Frm.value = amt001; } $100 $20 $10 $5 $1 25 cents 10 cents 5 cents 1 cent
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.