|
TOPICS IN MIS SPRING 2007 BU4045 |
|
Home | Syllabus | Journal | Project | Exam | Research | Gallery |
Thursday, April 12 2007
We are going to go over Javascript today and help you find Javascript in the textbook.
In Volume 2 of the text look on Page 696 at the bottom example on the page.
We will be looking for nine things when grading your analysis of Javascript on your site.
1) You get three points for identifying the program as JAVASCRIPT.<SCRIPT LANGUAGE=>
2) You get three points for identifying the variable declaration. (Var).
3) You get three points for identifying input/output (prompt and write).
4) You get three points for identifying if or switch statement.
5) You get three points for identifying the loop (For or While).
6) You get three points for identifying function body and function call.
7) You get three points for identifying an object/object member and value.
8) If you identify an Event you get 3 points
9) You get three points for identifying array.
<HTML><H1>Javascript search</H1>
<SCRIPT LANGUAGE="javascript"> This identifies the program as JAVASCRIPT
var english=["water","house","book","university","car","computer"];
var spanish=["aqua","casa","libro","universidad","caro","computador"];
These are the variable declarations. VAR
var result = 0;
var searchword = prompt("Enter english word to translate: "); This is the INPUT section
for(i=0;i<english.length;i++){ if(english[i]==searchword){ document.writeln("Spanish word: "+spanish[i]); result = 1; }//IF
THIS IS THE IF STATEMENT }//FOR THIS IS THE LOOP
if(result==0)
document.writeln("Sorry, NO MATCH for: " + searchword);
</SCRIPT> </HTML>
IDENTIFY a function by looking for the
FUNCTION DEFINITION and FUNCTION CALL in the JAVASCRIPT Program.
JAVASCRIPT has a lot of built in functions.
Many people have already written programs for Javascript.
You just have to find them.
JAVASCRIPT cannot manipulate files. You can only use ARRAYS to deal
with data.
In JavaScript when you see a . that means the value succeeding it is an object.
If you have a loop and within the loop there is an equality it means the Javascript program is a search engine.
JavaScript is a language that is embedded in HTML and is executed in a browser (Internet Explorer or Netscape). Almost every web page now utilizes JavaScript. While the name is JavaScript and people think it is related to Java, it is a distinct language by itself. Dealing with the Internet (Internet programming) is a common purpose of Java and JavaScript, and both are event-driven. The way JavaScript handles input (ex. an input value has to be parsed to its numerical value) is similar to Java. JavaScript can take advantage of HTML to make the page more presentable by using loops and if statements to manipulate many fonts, colors, etc. The syntax of JavaScript is very similar to that of C++ and JavaScript’s keywords are mostly from C/C++; out of 22 keywords, 17 are used in C++, 4 keywords are used in Pascal such as var, function, with, and in, and there are some other keywords such as null and typeof. The words write and writeln (write line) to display are also used in Pascal. JavaScript is an event-driven language that, upon certain events such as clicking the mouse or pressing a key, an action takes place.
You don't need a compile to execute JavaScript!!! It runs in your browser.
How do you convert 1-2-3 to 123? You multiply by 10 for each number.
1 X 10 = 10
10 + 2 = 12
12 X 10 = 120
120 + 3 = 123
There is a language called Alice- it is an event programming language.
The following code will put the date on the bottom of your page.
<script type="text/javascript">
var mydate=new Date()
var year=mydate.getYear()
if (year < 1000)
year+=1900
var day=mydate.getDay()
var month=mydate.getMonth()
var daym=mydate.getDate()
if (daym<10)
daym="0"+daym
var dayarray=new
Array("Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday")
var montharray=new
Array("January","February","March","April","May","June","July","August","September","October","November","December")
document.write("<span class='dates'>"+dayarray[day]+", "+montharray[month]+"
"+daym+", "+year+" ")
</script>
See below for an example of this code being executed.
For the class website we looked at Brown University. They had a unique navigation bar in that
it flips up with a different picture in each navigation subset.
