Advanced JavaScript

Home Up Substitute Functions Multiple Outputs 
This Page Format is Obsolete!  Go to new site : http://www.science-ebooks.com/javascript-js.html

This Site will go away in spring of 2016:  Please visit http://www.science-ebooks.com to see NEW SITE!

 

Substitute Functions
Multiple Outputs

series 2 pure

 

I have revised my lesson plan.  Only those of you who are already  well versed in JavaScript should start here! All others should start at: Free Tutorial - JavaScript Scientific Programming

Procedure for making text programs Run as code.
Step 1 -  Open a blank page in your Notepad (plan text editor).  Copy program including the top and bottom " HTML" tags and save as a text file. Name file " Text1A "

Step 2 - Save file again as a text file.  Name file " Page1A.htm " .  The file extension ".htm" tells browser that this file is a Web Page. 

Step 3 - Close Notepad (text editor).

Step 4 - Locate file " Page1A.htm ". Right click " Page1A.htm " file.  Select open with.  Select " Internet Explorer Browser."  At this point you should see a running program.  The file ext "htm" tells the Browser this file contains a Web Page.  The "<HTML>" tag " <Script Lanquage = JavaScript> " tag tells the browser to start interpreting text as a Script program.  The result of running program should be .3333333.   

Notes 

//indicates an optional comment field. 
var is used to assign value and declare variable.
Olive text provides HTML page with button and textbox to run your program and display text. The function mathgeneral provides a place for you to write a series of math statements( black text) that constitute your program. Alpha formats your numeric answer Rt into a string (text) variable. 

Blue text are  the labels for buttons.

Copy  text below from HTML tag to HTML tag. 

<HTML>

<head>
<SCRIPT LANGUAGE = JavaScript>

var Rt // declares variable total resistance 
var R1 = 1.0 
var R2 = 1.0 
var R3 = 1.0 
var recipRt //declares variable reciprocal of Rt
var clr = "" // empty global string variable
Alpha = "" // global string variable
function mathgeneral(){
recipRt = 1/R1 + 1/R2 + 1/R3;
Rt = 1/recipRt; Alpha = ("Rtotal is "+Rt);
document.B1.T1.value = Alpha}

</SCRIPT>
</head>
<body>
<p align="center">&nbsp;<b><font size="5" color="#808000">&nbsp;&nbsp;
Template
#1</font></b>
<p>&nbsp;</p>
<form name="B1">
<p align="center"><input type="button" value="
RUN" name="B1" onclick="mathgeneral();"><br>
<input type="text" name="T1" size="20">
<p align="center"><input type="button" value="
Clear Output" name="B2" onclick = "document.B1.T1.value = clr">

<p align="center">&nbsp;

</form>
<p>&nbsp;</p>
</body>

</HTML>

Copy  text above  from HTML tag to HTML tag.

 

Procedure for editing programs. ( Change Data)

Step 1 -  Open file "Text1A" with Notepad.  Modify data by making  R1 = 2 ( varR1=2).

Step 2 - Save modified file as text with file name "Text1B".  Then Save as text again with file name " Text1B.htm".

Step 3 - Close Notepad ( Text Editor ).

Step 4 - Locate file " Page1B.htm ". Right click " Page1A.htm " file.  Select open with.  Select " Internet Explorer Browser."  At this point you should see a running program. 

Step 5 - Run Program and note results.  Highlight text in text box and copy ( Control C key). 

Step 6 - Open Text1B  with Notepad and paste results at bottom of page.  You now have documented the results, data, and method used to solve a problem. You can file, print or merge this text into another document.   

 

Procedure for editing programs. (Change Formula)

Step 1 -  Open file "Text1A" with Notepad.  Modify data by making adding variable R4 and assigning a value  of 10 to it. ( varR4=10). Simply add line of text "varR4 = 10 below line " varR3 = 1"

Step 2 - Modify Math General Function to calculate resistance of four resisters in parallel. Modify line of code reading " recipRt = 1/R1 + 1/R2 + 1/R3;" to read " recipRt = 1/R1 + 1/R2 + 1/R3 + 1/R4; " .

Step 2 - Save modified file as text with file name "Text2A".  Then Save as text again with file name " Text2A.htm".

Step 3 - Close Notepad ( Text Editor ).

Step 4 - Locate file " Page2A.htm ". Right click " Page1A.htm " file.  Select Open With.  Select " Internet Explorer Browser."  At this point you should see a running program. 

Step 5 - Run Program (Click Run) and note results.  Highlight text in text box and copy ( Control C key). 

Step 6 - Open Text1A file with Notepad and paste results at bottom of page.  You now have documented the results, data, and method used to solve a problem. You can file, print or merge this text into another document.  

At this point you may realize that you can substitute almost any formula you want into the function mathgeneral. You have also learned how to use notepad and Internet Explorer as a Software Development system.

Continue on to lessons in left column.

   

 

 

Please email Bill with any questions or problems at BilPat4342@AOL.com

 

Next: Go to substitute functions.


        
Questions or problems regarding this web site should be directed to BilPat4342@AOL.com

Copyright ©2003 Science Ebooks All rights reserved.
Last modified: Monday January 18, 2016.