Saturday, November 15, 2008

JavaScript

We have been spending the last couple of weeks on JavaScript and we will continue to do more with it for the remainder of the semester. So far, the following has been assigned:

JavaScript Quiz #1: http://www.pgrocer.net/Cis44/assignments/JSXHTMLquiz1.html
JavaScript Quiz #2: http://www.pgrocer.net/Cis44/assignments/JSXHTMLquiz2.html

We will be spending time, in class, this coming week to work on JavaScript Quiz #1 and #2.
Please note that JavaScript Quiz #3 has been posted on the pgrocer.net website: http://www.pgrocer.net/Cis44/assignments/JSXHTMLquiz3.html. If you are brave enough, it is ready for you to tackle.

Please keep in mind that I realize that this is a bit challenging for you , especially if you have never programmed before. DON'T LET THIS FRUSTRATE YOU. I will be around to help you get through it! :)

I am planning on being at the Attleboro campus from 3PM to 4PM on the days that we meet, for those of you that may need additional assistance.

Our next meeting will be on Wednesday, November 19.
Wedensday, November 26 will be a distance learning class, therefore, we WILL NOT be meeting in person on this date.

Happy coding!
Rose

49 comments:

Your Instructor said...

Hello,

Mrs. Grocer had posted a link to her CIS17 samples. They are quite helpful, especially for quiz #1. We will be discussing them on Wednesday. In the meantime, if you have not already referenced them, you can find them at http://www.pgrocer.net/Cis17/cis17programs.html.

The JavaScript examples are at the bottom of the page. Come prepared with questions on Wednesday.

See you then!

Nan Tremblay said...

Well...so far, I managed to get 3 events on one page; starting to feel better about it, so I guess there is hope for me yet!! Now I am going to do another page with more events...loosing my fear. :~) !!

How's everyone else doing? Rita?

Bret Brown said...

Hi,

I found it easier for me to use a web page with the form tag and different controls on which to add support for the JavaScript events. With the form and controls some of the events just made more sense to me. For example, it was easy for me to think of how I might use the onblur event to validate the data entered in a control. I was struggling to think of how to use all of the events until I settled on a page for the form tag. Once I settle on this page, I was able to add the necessary JavaScript events on just one html page.

I hope this helps,
Bret

Nan Tremblay said...

Yes, I think you need a reason to use them first, otherwise it is harder to envision them. You need an object for them to work on.

Your Instructor said...

One thing I neglected to mention is that each quiz question should reside on its own page. You do not need to have all four questions within one .html file. I apologize for an inconvenience.

Again, we will be spending some more time on this during our next class.

Rose

Rita McLaughlin said...

so we are to do ALL of Quiz 1 and ALL of quiz 2?? Rose can you clarify this Please.

Nan Tremblay said...

Ok, now I am really confused:
I thought we were just coming up with 6 events on our own. Then, I thought we would be working in class for Quiz 1 & 2.

I look at them, but I don't know what I am doing with them. Re: "You need to write these two messages onto the form on two different lines." ??Sorry??
:~0

Rita McLaughlin said...

Nan - look carefully at the samples and you will see that the multiply one puts out the answers on two lines. You can use this as an example to start with.
Unfortunately, these word problems are written in a difficult fashion.
I just haven't looked at Quiz 2 at all simply ran out of life and time assigned for this class!
See you in class tomorrow!

Nan Tremblay said...

Rita,
Thank you for taking the time to respond. I appreciate it.

I am gradually finding information; and, yes, it IS unfortunate...

I may not get to Quiz 2 either; just reading a lot and doing the other stuff, and finishing up Quiz 1.

See you tomorrow.

Jessica Lappin said...

Hi,

I didn't look at the quizzes yet because I'm still working on javascript assignment and learning the codes. I'm almost done and I need to work on the last event of the javascript.

Also, here are the links about javascript I found online:

http://www.echoecho.com/javascript.htm

http://www.freewebmasterhelp.com/tutorials/javascript

I'm going back to work on javascript assignment. See you later!

Jessica Lappin

Bret Brown said...

Hi,
If anyone is working on JavaScript Quiz # 3; I wanted to let you know that the examples for Question # 2 on pgrocer.net don't work correctly in Internet Explorer.

Here is a link that describes what IE does differently:

http://javascript.about.com/library/blwrite.htm

Ultimately following the example ths part of the quiz doesn't work in IE. What happens is that you can't see the questions in the window that you are supposed to answer. So if you can't see the question it is hard to enter the right value.

If you click cancel in the prompt window to stop the quiz, then all of the prompts and you answers will display.

The example does work with Firefox.

Bret

Nan Tremblay said...

I am finding that many of these code sample prompts block the question in Firefox. Also, you can't break out of it, so it just jams the browser window.

Bret Brown said...

Nan,
Some of the examples are coded with errors. In some cases this may be an indication that there have been changes to the JavaScript language itself. Some of the quiz problem are intentionally coded incorrectly and we are supposed to 'fix' the code. There was one quiz problem that said that there was an endless loop that we had to fix.

If you look at the JavaScript code closely you may see that the problem is really in the JavaScript code and this is why you can't break out. Clicking the cancel button will only break out if the JavaScript code recognizes that cancel was clicked.

Bret

Bret Brown said...

Hi,

Here is a link that does a reasonable job describing variables in JavaScript. Maybe this will help reinforce some of the things that Rose went over in class last night. I hope it helps. I learned a few things that I didn't understand before I read this.

JavaScript Variables

Bret

Bret Brown said...

Hi,
On Wednesday evening, Nan described a desire to use JavaScript events to validate information entered on a html form. This is an area where JavaScript is used quite often.

Nan wanted to validate that the email address was valid from a format point of view. I don't know of any way to determine if the email address is actual an existing email address.

I gave Nan some code that I had found in a book that I have. The JavaScript code uses a built in set of functions that fall into a category called 'regular expressions'. The name, at least for me, doesn't really mean anything. I would use the term 'pattern matching' because I think that it describes more clearly what regular expressions are used for.

Regular Expressions are very powerful and are used frequently by people with speciailized roles involved in developing software. However, for me they are very confusing. I've used them in the past and because they are so powerful that can save many hours of time trying to figure out how to validate, for example, that an email address fits the standard pattern for an email address.

But since I don't use them frequently, when I need to use them I always try to find the places I used them before and copy and paste and then struggle to make the changes I need to make to do what I need to do.

I found a web site on regular expressions support in JavaScript. Here is the link to this site.

JavaScript Regular Expressions

In the past only specialized programming languages supported regular expressions but now all of the most popular programming languages support them and nearly all programming languages support them. So just knowing that they exist may help you in the future becuase you can usually find a web site or book that contains a description for how to use regular expressions to do what you need to do.

I hope someone finds this interesting if not useful at this point in time.

Bret

Bret Brown said...

Hi,

For some reason the link I posted doesn't work. Here is the url for the web site that describes the JavaScript 'Regular Expression' support.

http://www.javascriptkit.com/jsref/regexp.shtml

Bret

Nan Tremblay said...

Rose,
Thank you for helping me before class....it made a big difference.

Bret,
Thanks for the links. And look what is in there:
http://www.javascriptkit.com/script/script2/acheck.shtml
An email one!

I will try it out tonight.

Nan Tremblay said...

Bret,

I managed to put the email validation on my Civil War Reenactors Gazetter site, on the page for trading post:

http://www.aurora4.addr.com/NewHampshireVolunteersReenactorsGazette/tradingpost.html

I am going to put it on my Javascript event exercise (2 pages of goofy), as well.

It works on Safari, Firefox, Netscape and IE.

Thanks for your help. :~)

Rita McLaughlin said...

Nan & Bret - here's the falcon link:
http://www.dep.state.pa.us/dep/falcon/

I think it will be more active come spring.

Back to class, were we officially assigned Quiz2 &3 to do?
Thanks!

Nan Tremblay said...

Rita,
Yes, Quiz 2 is due this Wednesday and Quiz 3 is due the following Wednesday.

James said...

Was the quizzes difficult? We just have to comment out what we are adding correct?

Rita McLaughlin said...

Thanks Nan - I also saw where it was posted at the top of this blog.

Rita McLaughlin said...

Bret - I found that the last sample for multiple guesses doesn't work either in Firefox nor IE7. Maybe it would work in an earlier version of IE.
Do we have samples of functions working in the head portion?

Nan Tremblay said...

Hmmm.....
I am stumped on Question 3, on Quiz 2.

I'm not seeing any code in the class stuff that is pertinent. At first I thought I would approach it as an array, but I don't understand it.

Then I tried another approach, but I am not doing too well.

I feel I am playing 20 Questions.

Rita McLaughlin said...

Nan - I also am stumped on Problem 3. I also can't get my prob 2 to work. Plus I can't get the presentations to either save or download as powerpoint presentations. I am totally frustrated.

Rita McLaughlin said...

Nan- this is a for loop. I have an example in my xtml book. Because only 1 radio button can be "on" at a time you have to check them in a loop. I don't know if there is an example of this in the presentations or not as I have not been back to check. The presentations now seem to be in .html format not the power point format.
Plus after looking at this in my book; I can see that this is a difficult concept and probably needs to be taught in class, I've had this concept so I understand it.
Check your book, you have have it also. I'll try to answer any questions you have.

Happy thanksgiving All!

Nan Tremblay said...

Rita,
Thanks for helping me.

I worked on it for a long time, without making progress and finally got really exasperated. I am not a programmer!...and holidays require family obligations (cleaning and cooking).

Not all the Powerpoint files worked. I find them ineffective anyway. Too many assumptions are made, ignoring the knowledge base of non-programmers.

I will try the loop approach, although they are not radio buttons. I did find something that worked, but it is totally irrespective of the code that is in the question, and I assume one must still adhere to that approach, rather than go totally solo.

The book I just bought barely touches on Javascript....I will keep looking...or go solo.

Rita McLaughlin said...

Nan- you are correct - this is not radio buttons, but it is buttons that can only have 1 set at a time.
Once you get input, each button will have to be checked: Were you clicked? no? then check the next one until you find the one that got clicked. Then the background color gets changed.

I need to see an example of this before I can code it; it's just the way I am.

Nan Tremblay said...

Rita,
You are right....I hadn't thought of it that way...they are the equivalent of radio buttons. Thanks! I will try again.

Nan Tremblay said...

I just checked my BCC email, which I had not done for a few days and saw that Rose was in a car accident. Thank God they are all ok! But her car is not.

Nan Tremblay said...

I managed to complete the 3rd question on Quiz 2 (I guess).

Quiz 3 looks harder. Is anyone else having difficulty?

Jessica Lappin said...

Yea, I just completed quiz 2 just now! I just looked at quiz 3 and it looks even harder because the quiz is mostly about loops with javascript. I never learn about loops with java. I'm going try my best! Good luck!

Rita McLaughlin said...

Nan - Thats great that you finished all of Quiz 2! My mind sorts quit.
Did you find any examples for Quiz 2/prob. 3 ? Quiz 3 does look more difficult.

Nan Tremblay said...

Rita,
I spent hours on this...totally confused. I could not reconcile the presented script, with samples I found or even the concepts. I finally just found a script, on I THINK:
http://www.w3schools.com/js/js_examples_2.asp, that is an array, which I adapted. Now I can't find it, but let me look for it and I will post the link. I have to go out first though.

Meanwhile, yesterday, I came across another source of info, which Bret posted. Lots of good stuff, buried in the site; check out the tutorials
http://www.javascriptkit.com/

I like it because the tutorials actually explain concepts more, rather than just throwing abstract scripts at me, which I just don't understand from the beginning.

James said...

I am having a hard time with the quizzes myself. It just is not totally making sense to me.

Nan Tremblay said...

Rita,
Re: quiz2/question3
I can't find the one I saw, but I have found another one that accomplishes the same thing, and they approach it as an array. Each array item, brings an assigned response (the color change), when you mouseover or click it's corresponding link. (substitute buttons for links in the body).

http://www.webdesign.org/web/web-programming/javascript/changing-the-background-colour.6199.html

When I first look at these questions, I am not always sure what approach to take (or why). I guess that is why I have been feeling overwhelmed with scripts or code. Hopefully, it will get better.

Nan Tremblay said...

Hi,

I noticed that the last 2 Javascript Powerpoint presentations were not accessible before and I recall they were going to be reconnected? Now when I go to them, something comes up but there are still problems making them unreadable for me:

There is nothing to load if I try to click it from Firefox or Netscape. On Safari, the presentation opens on an html page, as if it is being presented in a frameset. However, the main slide is much too small to read.

Rita McLaughlin said...

thanks Nan. I'll see you tomorrow!

Nan Tremblay said...

Well....I am pondering the class scripts and wondering which one(s) pertain to Question 3 on Quiz 3....but, alas...

I can look at them, understand them in that context only, but I am not able to work with them. Sigh...

I will try other questions.

Rose and Bret, thank you for your help on Wednesday.

Jessica Lappin said...

Hi everyone,

I'm so stuck on quiz 3 because I do not understand how javascript loops work. I got problem first to work to put a password to get on pgrocer website but I don't know how to write a code for loop. Other problems I try to figure out and I try to write the code from pgrocer website but I don't understand and I'm stuck on this quiz. Can anyone explain me how the loop works on javascript? I will try work on it but I will work more on second website project assignment with javascript. I'm trying my best on quiz 3 but this is more hard and confused than other 2 quizzes.

Thank you,

Jessica Lappin

Nan Tremblay said...

Jessica,
I am in the same position. I got the password part in, but I cannot loop it. Then I tried to work with some of the other questions, but did not get far.

I can spend hours trying to use them on my own, but if I can't get them, time is ticking. I will keep trying, but for now, I have to turn to the other assignment, applying Javascript to my website.

James said...

I have been not able to get the quizzes done as i have been sick in bed for the last 4 days.

Anonymous said...

I've also been sick lately but I'm back to working on Quiz 3, and I'm still stuck on Question 2. I put in a loop to repeat the prompt until a correct answer is given, but it does not show the next question before prompting for the answer. If anyone is working on this and can help me out I'd appreciate it because i'm completely lost on how to fix this. Thanks!

Bret Brown said...

Hi,
I've copied the web page that I presented tonight under my comcast personal web pages. The Sample Code link will take you to a page that contains the JavaScript that I used for most of the pages in this web site.

The url is http://home.comcast.net/~bret.brown/javascript/

You can also try to click the link:

JavaScript Presentation

Rose, thank you so much for your patience and guidance through the material. I've learned a lot by taking the class.

Bret

Nan Tremblay said...

Bret,
I liked your Javascript site!

Rose, thank you so much for your help!!

Nan Tremblay said...

Hi,
I have not been able to do all of Quiz 3. I only got as far as Quesiton 1 (finally got it to work). I could spend more time on it, but I turned my attention to my website. Will go back to it after that. I am about to upload my Javascript version of my website.

My question is: I was 15 min. late last Wed and I'm sure I missed comments re: our final status etc. I looked at pgrocer and see the exam and the status page, so I wondered if this is what we will be doing and do we use the status sheet?

Hope all are well.

Jessica Lappin said...

Hi,

I am also working on quiz 3 and still working on first question for almost week and half. I finally figured out how to use while loop but I'm stuck little bit because when I type right password in second try, it will keep looping to third try. When I type right password on third try, it will not go to pgrocer website. But, on the first try, I typed right password, it will go to the website but not on 2nd or 3rd try. I figure out how to do while loop but I'm having trouble on 2nd and 3rd try. Arr!

I just hope I can do other 2 problems by Wednesday. :-\

Nan- During the first 15 min of the class, we didn't talk about the final status. We talked about the presentations like who will go up, etc. and quizzes. I don't know we need to final status.

Anyway, I'm going work on quiz 3 and try to get the second and third try work when I type right password to pgrocer website.

Jessica

Nan Tremblay said...

Jessica,

Thank you for responding to my question. I looked at the pgrocer exam, but I guess we won't be doing that. Quiz 3 is just hard for us, I guess. I will just muddle through.

I uploaded my web site again with some Javascript. I put some onclick open-in-a-new-window stuff, a live dateline script, a simpler email validation code and some music on the Trading Post page. I was confused on commenting out scripts (kept commenting out the whole thing), but I have it now.

http://www.aurora4.addr.com/NewHampshireVolunteersCivilWarReenactorsGazette/

Anonymous said...

Here is the link to my website:
http://home.comcast.net/~nat187/
I've updated it to include some JavaScript.