Writing to the Page Formatting Forms

Slides:



Advertisements
Similar presentations
The Document Object Model (DOM) 1 JavaScript is an object-based language—that is, it’s based on manipulating objects by changing each object’s properties.
Advertisements

HTML 5 and CSS 3, Illustrated Complete Unit L: Programming Web Pages with JavaScript.
Lesson 12- Unit L Programming Web Pages with JavaScript.
The Web Warrior Guide to Web Design Technologies
JavaScript 101 Lesson 5: Introduction to Events. Lesson Topics Event driven programming Events and event handlers The onClick event handler for hyperlinks.
Introduction to Javascript. Web Page Technologies To create Web Page documents, you use: To create Web Page documents, you use: HTML – contents and structures.
JavaScript onLoad getElement. onload Using JavaScript to create content No user input Comes up when page LOADS [redo Koozebane; random picture]
1 Events Lect 8. 2 Event-driven Pages one popular feature of the Web is its interactive nature e.g., you click on buttons to make windows appear e.g.,
CP476 Internet Computing JavaScript and HTML1 1.JavaScript Execution Environment The JavaScript Window object represents the window in which the browser.
Event Handlers CS101 Introduction to Computing. Learning Goals Learn about event handlers Determine how events are useful in JavaScript Discover where.
JavaScript Part 1.
SERVER web page repository WEB PAGE instructions stores information and instructions BROWSER retrieves web page and follows instructions Server Web Server.
CSS Class 7 Add JavaScript to your page Add event handlers Validate a form Open a new window Hide and show elements Swap images Debug JavaScript.
JavaScript, Fourth Edition
CO1552 Web Application Development HTML Forms, Events and an introduction to JavaScript.
JavaScript, jQuery, and Mashups Incorporating JavaScript, jQuery, and other Mashups into existing pages.
PHP Form Introduction Getting User Information Text Input.
Button and Textbox. Input  Input objects are used to obtain input from the user viewing the webpage. They allow the user to interact with the Web. 
SERVER web page repository WEB PAGE instructions stores information and instructions BROWSER retrieves web page and follows instructions Server Web Server.
Lecture 10 JavaScript: DOM and Dynamic HTML Boriana Koleva Room: C54
CONDITIONALS DATE CHANGES OUTSIDE FORMS. CONDITION ALS.
CSS1 Dynamic HTML Objects, Collections & Events. CSS2 Introduction Dynamic HTML treats HTML elements as objects. Element’s parameters can be treated as.
1 Javascript DOM Peter Atkinson. 2 Objectives Understand the nature and structure of the DOM Add and remove content from the page Access and change element.
How to Use Google Charts. Using Google Charts Google Charts is used to provide a way to visualize data on your website. You can choose to use simple line.
4. Javascript M. Udin Harun Al Rasyid, S.Kom, Ph.D Lab Jaringan Komputer (C-307) Desain.
1 CSC160 Chapter 7: Events and Event Handlers. 2 Outline Event and event handlers onClick event handler onMouseOver event handler onMouseOut event handler.
JavaScript Challenges Answers for challenges
Event Handling. Objectives Using event handlers Simulating events Using event-related methods.
INT222 - Internet Fundamentals Shi, Yue (Sunny) Office: T2095 SENECA COLLEGE.
CIS 3.5 Lecture 2.3 "Introduction to JavaScript".
Javascript Overview. What is Javascript? May be one of the most popular programming languages ever Runs in the browser, not on the server All modern browsers.
Document Object Model Nasrullah. DOM When a page is loaded,browser creates a Document Object Model of the Page.
GetElementById changes outside forms. From form to page  Identified the field by using name  Form.field  Outside a form, use id  Unique on the page.
JavaScript Events Java 4 Understanding Events Events add interactivity between the web page and the user You can think of an event as a trigger that.
CSD 340 (Blum)1 Introducing Text Input elements and Ifs.
1 Lesson 6 Introducing JavaScript HTML and JavaScript BASICS, 4 th Edition.
CSC 121 Computers and Scientific Thinking Fall Event-Driven Programming.
JavaScript Events. Understanding Events Events add interactivity between the web page and the user Events add interactivity between the web page and the.
Client-side (JavaScript) Validation. Associating a function with a click event – Part 1 Use the input tag’s onclick attribute to associate a function.
A little PHP. Enter the simple HTML code seen below.
ADMINISTRIVIA. LATES, REGRADES, …  Regrades: no more forms: need to see me in person in my office  Excused absences  If foreseeable, needs to be requested.
Event-Driven Programming
A little PHP.
CIIT-Human Computer Interaction-CSC456-Fall-2015-Mr
Introduction to JavaScript Events
JavaScript.
JavaScript functions.
Intro to JavaScript CS 1150 Spring 2017.
Chapter 14: DHTML: Event Model
JavaScript, continued.
JAVASCRIPTS AND HTML DOCUMENTS
4. Javascript Pemrograman Web I Program Studi Teknik Informatika
14 A Brief Look at JavaScript and jQuery.
Functions BIS1523 – Lecture 17.
Event Driven Programming & User Defined Functions
Chapter 4 JavaScript and Dynamic Web Pages
Javascript Game Assessment
CHAPTER 7 JavaScripts & HTML Documents
Reviewing key concepts
Writing to a PAGE.
Web Design and Development
Select tags CSD 340 (Blum).
Training & Development
JavaScript Basics Topics Review Important Methods Writing Functions
Chapter 7 Event-Driven Pages
Introduction to Programming and JavaScript
Web Programming and Design
Web Programming and Design
Web Programming and Design
Writing to a PAGE.
Presentation transcript:

Writing to the Page Formatting Forms

Lab starting point (review) Create an HTML page that has a form on it with 2 input fields for a first name and a last name, each with a label Button that when clicked creates an alert that says Hi first-name

getElementById

CHANGING HTML General structure: document.getElementById(“id-name”).attribute document.getElementById(“id”).innerHTML document.getElementById(“id”).className document.getElementById(“id”).src

Changing content

Writing to the page Use an id on any element Replace the element using innerHTML Keeps the correct tags (meaning) in HTML

What to Write Generate HTML that you want. Concatenate literals and variables. Example: Build a paragraph using a variable called “content” document.getElementById(“id”).innerHTML = ‘<p>’+content+’</p>’;

Changing classes

Changing class example document.getElementById(“id”).className =‘highlight’; And define that class in the CSS

Mouseover example Highlighting when mouseover Requires that you change it back when you mouseout onmouseover= “document.getElementById(“id”).className=‘highlight’;” onmouseout= “document.getElementById(“id”).className=‘normal’;“

Changing images

Changing src example Change the picture with a button click onclick= “document.getElementById(“id”).src=‘cow.jpg’;”

Onclick Options

Simple Change Onclick makes the change in a simple assignment statement document.getElementById(‘newfield’).innerHTML = ‘This is new content!’; Requirement: newfield is an id on the page whose content can be changed Very often there is no information there yet

Or Use User Input Onclick still makes the change in a simple assignment statement What is assigned changes: document.getElementById(‘newfield’).innerHTML = ‘Hi ’+document.getElementById(‘yourname’).value; Same requirements on newfield

From alert to text Create an empty paragraph below the form Instead of an alert, add the text to the page

Changes more complex than a single assignment

Use a function instead of a literal Onclick STILL makes the change in a simple assignment statement document.getElementById(‘newfield’).innerHTML = newcontent(); Same requirements on newfield

But only interesting if content can change Content is random Content cones from user input Function needs to return a value return(value);

Random content Same onclick document.getElementById(‘newfield’).innerHTML = newcontent(); Function change: newcontent uses Math.random();

User Input Now onclick passes a parameter document.getElementById(‘newfield’).innerHTML = newcontent(document.getElementById(‘you’).value); Function change: newcontent now takes a parameter and uses it;

Adding a function Change the onclick to call a function that you are to write.