YEAR 12 DIGITAL TECHNOLOGY
  • Home
  • Website
    • Term 1 Overview
    • Learn Basic HTML
    • Learn Basic CSS
    • HTML/CSS Advanced
    • Photoshop Level 2
    • Recap and Review
    • Conventions of Web Design
    • AS91893 - Digital Media Outcome >
      • AS91893 - Resources
  • Programming
    • Term 2 Overview
    • JavaScript Recap
    • JavaScript and HTML
    • Functions, Parameters and Returns
    • Learn Arrays
    • AS91896 - Brief
  • Databases
    • Term 3 Overview
    • Learn Access >
      • Intro to Access
      • Relationships and lookups
      • Relationships Extended
      • Queries and Reports
      • Mail Merge
      • Car Sales
      • Documentation x5
      • Importing Data
  • External
    • Computer Science External
    • A.I. 2024 >
      • 2024 Exam Update
      • Adoption of AI
      • Mechanisms & Techniques
      • Impact of AI
      • Key Issues
      • A.I. Practice Exams
    • Optional - Present a summary
    • External Rules
  • Innovation
    • Innovation Pathway
    • AS91891 - Concept Design
    • AS91897 - Advanced Outcome
    • AS91893 - Digital Media Outcome
    • AS91894 - Electronics
    • AS91896 - Programming
    • AS91368 - Brief
  • Freyberg Digital

Learn Basics - JavaScript, HTML and Forms

HTML and JavaScript
We can use HTML to create forms and program websites.

This can make websites dynamic and interactive.


This tutorial you will be creating a madlibs activity as a final result.
Picture

Changing HTML

JavaScript can be used to change HTML

This is done using ID's. You can give HTML elements such as <div> and <span>
unique id's.
Task: update HTML using a button.

1.) Create a new HTML file.
2.) Enter the doctype and a heading.
3.) Enter the following div tag:
<div id="changeMe"> I will be changed </div>
4.) Create a button that calls a function called "changeHTML()"
5.) Insert this code:
 document.getElementById("changeMe").innerHTML = "Changed"
6.) Run the program
Picture
Div Tags
Div tags will create brand new HTML when used (divide). Anything under Div will start on a new line.
Span Tags
Span tags will inherit the previous HTML tags. Anything under Span tags will be on the same line.
Picture
TASK: Add the following to your page:
- Another button called "change by name"
- A function called "changeByName"
- Make it so that when you click the button it asks for the users name and includes it in the changed text

Brief: Create a button that makes itself disappear

Task: Create a button that when clicked will create another button.
When the other button is clicked it will make itself disappear.


​

Getting information from boxes
Rather then using unsophisticated prompts and alerts we can now use fancy input boxes.

Here is the code for the boxes:

HTML:
<input type="text" id="firstName"> </input>

JavaScript:
document.getElementById("firstName").value;

With this code you should be able to create the app on your right :-)
Picture

Brief: Booking a lobotomy

Using <input type="date"> and <input type="time"> let a user input their first name, last name and book their very first lobotomy.

​It should come up with a message confirming their lobotomy

Extra: Make a some text appear warning them of the side effects of the lobotomy and a button to confirm.
Picture

Checkboxes

Check Boxes.

As part of the assessment for term you will want to get values from check boxes. This section will show how we use these work.

Check Boxes.

In HTML a checkbox looks like this:
<input type="checkbox">​
If you want to get information from it you would add:
"id=largeSize"
And if you wanted an option to be checked you would do this:
"checked=true"

When we get information it will look like this:
let large = document.getElementById("largeSize").checked;

Task: Create a list of checkboxes for pokemon you like to eat.
1.) Create the checkboxes
2.) Create a button for ordering
​3.) When clicked it should list the items you have purchased.

Extra for experts: Program it so that if none of the boxes are checked it states: you have ordered northing.
Picture
Picture
Picture
Hint: You actually don't need "== true" in an if statement.

You can just write
​if(document.getElementById("mewTwo").checked)


Brief: Minesweeper

Create a series of checkboxes (minimum 5) and a button that says "step on mines".
If they have checked the wrong boxes they should "blow up"
If they have only clicked the right ones give them a score. (such as 3 out of 4).
Extra for experts: Everytime they click step on mines, clear the checks from the checkboxes.

Radio Buttons

Radio buttons can be used when you want to force users to choose a limited set of options:

Do you want fried with your burger?:
Yes  ()    No ()

What makes radio buttons different is that you can group together the boxes and force students to make a selection.

Task: Fix the HTML
I have created 3 groups of HTML radio buttons that do not work together.

Try and fix them up so that you can only pick one from each group.

<<Hint>> Use "name" to group together buttons.

radio.zip
File Size: 0 kb
File Type: zip
Download File

Task: Choose a version of Pokémon

1.) Create a webpage that has 4 different radio buttons for different pokemon versions.
2.) Create a button that when clicked shows the cost of that pokemon game.
Picture
Picture
Picture
Picture
Picture

Brief: Unlock the secret combination

Create a webpage with a series of radio buttons and check boxes and a button.
If the right buttons and radio buttons are clicked then give them a secret answer.

External JavaScript Files

Rather then have your script all on one page we can actually have it in a separate file.

1.) Open any of your previous projects in Code.
2.) Create a new file call it "code.js"
3.) Copy all the code from inside the <script> tags into your js file
4.) Inside your script tags add:

src="code.js" type=text/javascript

5.) Test your app
Picture

Drop Down Lists

Task: Learn for yourself

1.) Go to w3 schools input dropdown.
www.w3schools.com/html/html_form_elements.asp
​
2.) Create a drop down list of whatever you want
​3.) Create a button that when clicked will alert you to what option you choose in the dropdown list.


Picture

Checkpoint: Create this Madlib activity in JavaScript

Picture
Tip: Rome wasn't built in a day. Don't try to do it all at once, break it down into small steps that you can do.
Using input boxes ask for the following:
- Name A
- Name B
- 2 Numbers
- A Thing

Once the user hits submit, it should automagically create the madlib filled in on the left.

It should also calculate how many each they have in total

You will need to remember to use the following code:

Number()
+=
document.getElementById().value
document.getElementById().innerHTML
Powered by Create your own unique website with customizable templates.
  • Home
  • Website
    • Term 1 Overview
    • Learn Basic HTML
    • Learn Basic CSS
    • HTML/CSS Advanced
    • Photoshop Level 2
    • Recap and Review
    • Conventions of Web Design
    • AS91893 - Digital Media Outcome >
      • AS91893 - Resources
  • Programming
    • Term 2 Overview
    • JavaScript Recap
    • JavaScript and HTML
    • Functions, Parameters and Returns
    • Learn Arrays
    • AS91896 - Brief
  • Databases
    • Term 3 Overview
    • Learn Access >
      • Intro to Access
      • Relationships and lookups
      • Relationships Extended
      • Queries and Reports
      • Mail Merge
      • Car Sales
      • Documentation x5
      • Importing Data
  • External
    • Computer Science External
    • A.I. 2024 >
      • 2024 Exam Update
      • Adoption of AI
      • Mechanisms & Techniques
      • Impact of AI
      • Key Issues
      • A.I. Practice Exams
    • Optional - Present a summary
    • External Rules
  • Innovation
    • Innovation Pathway
    • AS91891 - Concept Design
    • AS91897 - Advanced Outcome
    • AS91893 - Digital Media Outcome
    • AS91894 - Electronics
    • AS91896 - Programming
    • AS91368 - Brief
  • Freyberg Digital