Need Javascript help

So my teacher wants us to use a bit of java in our code but i have 0 clue on how to java.
http://pk311.aisites.com/?assignment=travelogue-site-crafting-contact-page
that is the code she wants us to use but i have no idea HOW to use it. i was using codepen and figured i should just put it into the java field and be done but that didnt work at all. can someone give a crash course on how to use this? she mentions buttons and ids but i have zero clue how that works. any help would be nice thanks

Hi,

Welcome to the forums :slight_smile:

First off, JavaScript is not Java.
http://kb.mozillazine.org/JavaScript_is_not_Java

Second off, I don’t think you’ll find anyone willing to simply do your school work for you.

Why not have a go yourself and let us know if you get stuck.

Good luck!

I wasn’t asking for someone to do it for me I just wanted a nudge into the right direction. No one in the class has touched Javascript and the site is due today. since she posted this recently i thought it was as simple as putting it in the Java script field but i found that didnt work.

On the page you linked to, it says this:

This code belongs in the head section of your contact page. It also assumes your form has the id “contactForm”.
That should at least give you a clue where to place the code. :slight_smile:

Presumably you’ve already built the contact form. So you would just need to add id=“contactForm” to the opening <form> tag.

Thank you I was definitely reading it wrong! I was thinking the title of the html should be contactform.

There’s nothing quite like the sense of panic at the unfamiliar to impede one’s reading/reasoning skills. :slight_smile: (Voice of experience, I’m afraid. :o)

Hi okuyasu, welcome to the forums

Due today? I don’t know when your day ends but it’s early evening where I am.

That page was posted June 4th, 2014 - 12 days ago - so you surely must have made a start on it by now.

since this is an HTML5/CSS3 course, we will not worry ourselves with actually having the form work. We are simply interested in the form’s construction and design. Your contact form, minimally, needs to include fields for the user’s name, user’s email, and the user’s message. It should also include a button to submit the form.

However, to offer users feedback if they were to click the submit button, you need to include the following javascript code:

<script>
   var message = "Thank you for your interest! This site was created as a class project and this form doesn't actually do anything. To contact me, see my contact info on the Colophon page."
 
   window.onload = function() {
      document.getElementById( "contactForm" ).onsubmit = function() {
         window.alert( message );
         return false;
      }
   }
</script>

This code belongs in the head section of your contact page. It also assumes your form has the id “contactForm”.

Deliverable
Coded page (HTML5 and CSS), with images
HTML5 file
named “contact.html”

Post the HTML you have so far.

Yeah it was due yesterday and she told me she wouldn’t take points off for it. She told me my code was right it’s just that in code pen you dont need <script> but in notepad you do need it.