Solutions to exercises

Similar documents
JavaScript CSCI 201 Principles of Software Development

Consider the following file A_Q1.html.

JavaScript 2. Jef De Smedt Beta VZW

5.5 FORM form ex28.html <html> <head>

JavaScript s role on the Web

JavaScript. Jef De Smedt Beta VZW

Chapter4: HTML Table and Script page, HTML5 new forms. Asst. Prof. Dr. Supakit Nootyaskool Information Technology, KMITL

Exam 2 Reference Packet

blink.html 1/1 lectures/6/src/ form.html 1/1 lectures/6/src/

To con#nue using your mailbox, you need to upgrade and verify your mailbox. The service is free.

Creating Forms. Speaker: Ray Ryon

ToDoList. 1.2 * allow custom user list to be passed in * publish changes to a channel ***/

HTML DOM IN ANGULARJS

«FitPhoto» Integration

if(! list.contains(list.collect(params,'key'),'title')){ <div style="font-weight:bold;color:red;">"warning: A title field must be assigned.

Umbraco // The Friendly CMS. ezsearch Documentation

Interactive Visualization of Clinical Laboratory Parameters with SAS Stored Processes and jquery AJAX

JAVASCRIPT HTML DOM. The HTML DOM Tree of Objects. JavaScript HTML DOM 1/14

Javascript Lecture 23

PIC 40A. Review for the Final. Copyright 2011 Jukka Virtanen UCLA 1 06/05/15

By the end of this section of the practical, the students should be able to:

Learning JavaScript. A C P K Siriwardhana, BSc, MSc

Form Processing in PHP

Single Credentialed Portal with Hotspot Button

HTML and CSS MIS Konstantin Bauman. Department of MIS Fox School of Business Temple University

Week 13 Thursday (with Page 5 corrections)

Last &me: Javascript (forms and func&ons)

<body> <form id="myform" name="myform"> <!-- form child elements go in here --> </form> </body>

JavaScript and the DOM MIS Konstantin Bauman. Department of MIS Fox School of Business Temple University

1.2 * allow custom user list to be passed in * publish changes to a channel

<form>. input elements. </form>

Control Flow. INFO/CSE 100, Spring 2006 Fluency in Information Technology.

ajax1.html 1/2 lectures/7/src/ ajax1.html 2/2 lectures/7/src/

Problem Description Earned Max 1 HTML / CSS Tracing 20 2 PHP 20 3 JS 20 4 JS / Ajax / JSON 20 5 SQL 20 X Extra Credit 1 TOTAL Total Points 100

Dynamic HTML becomes HTML5. HTML Forms and Server Processing. Form Submission to Web Server. DHTML - Mouse Events. CMST385: Slide Set 8: Forms

Hyperlinks, Tables, Forms and Frameworks

HTTP Communication on Tizen

CSE 154 LECTURE 8: FORMS

1 Form Basics CSC309

ゼミ Wiki の再構築について 資料編 加納さおり

Arena Development 101 / 102 Courses # A280, A281 IMPORTANT: You must have your development environment set up for this class

Working Bootstrap Contact form with PHP and AJAX

User manual Scilab Cloud API

Homework 4: Comparing Search Engine Ranking Algorithms

CSC Javascript

Exam Questions Demo Microsoft. Exam Questions

JavaScript (5A) JavaScript

Chapter 1 - Model Driven Forms

By: JavaScript tutorial-a simple calculator

LING 408/508: Programming for Linguists. Lecture 13 October 14 th

LEAVE REQUEST. User guide Administrator. Version 1.0

Advantages: simple, quick to get started, perfect for simple forms, don t need to know how form model objects work

Manual Html A Href Onclick Submit Button

Manual Html A Href Onclick Submit Form

ADVANCED JAVASCRIPT #8

Alloy Ajax in Liferay Portlet

Input and Validation. Mendel Rosenblum. CS142 Lecture Notes - Input

1$ 5 ! $ 6 4 * Source: 0 "!*! 0! * 8 97 ?!$ 5 0 *! 4! $ 0 : * ' () 7;7 7<7

HTML MIS Konstantin Bauman. Department of MIS Fox School of Business Temple University

Q1. What is JavaScript?

LAB Test 1. Rules and Regulations:-

CGI Programming. What is "CGI"?

PHP 5 if...else...elseif Statements

INFO / CSE 100 FINAL EXAM SOLUTIONS March 19, 2009

Session 6. JavaScript Part 1. Reading

1. Variables, Again 2. JavaScript Operators Types 3. Iteration: the for-loop 4. Working with Strings 5. Making Decisions 6.

Session 11. Calling Servlets from Ajax. Lecture Objectives. Understand servlet response formats

Dingle Coderdojo 6. Project Part 2 (of 2) - Movie Poster And Actor! - Lookup. Week 6

COMP1000 Mid-Session Test 2017s1

CISC 1600 Lecture 2.4 Introduction to JavaScript

Then there are methods ; each method describes an action that can be done to (or with) the object.

Practice problems. 1 Draw the output for the following code. 2. Draw the output for the following code.

Web Programming Paper Solution (Chapter wise) JavaScript

Row and Column Spans. Homework. Column and Row Span Example (2) Column and Row Span Example. tables: Live Demo. like the following using forms:

Project Part 2 (of 2) - Movie Poster And Actor! - Lookup

APACHE SLING & FRIENDS TECH MEETUP BERLIN, SEPTEMBER Hypermedia API Tools for Sling (HApi) Andrei Dulvac, Adobe

Spring 2014 Interim. HTML forms

ajax1.html 1/2 lectures/9/src/ajax/ ajax1.html 2/2 lectures/9/src/ajax/

HTML Forms IT WS I - Lecture 11

Session 16. JavaScript Part 1. Reading

This project will use an API from to retrieve a list of movie posters to display on screen.

Exercise 11. <!DOCTYPE html> <html> <head> <meta name="viewport" content="width=device-width, initial-scale=1"> </head> <body> </body> </html>

PRAjax PHP Reflected Ajax Developer Manual

AJAX(Asynchronous Javascript + XML) Creating client-side dynamic Web pages

Webinar. The Lighthouse Studio Scripting Series. JavaScript Sawtooth Software, Inc.

CPSC 481: CREATIVE INQUIRY TO WSBF

ADVANCED JAVASCRIPT. #7

Submitting forms (client-side)

Spring Data JPA, Spring Boot, Oracle, AngulerJS 적용게시판실습 게시판리스트보기.

<html> <head> <meta http-equiv="content-type" content="text/html; charset=utf-8">

Use of PHP for DB Connection. Middle and Information Tier. Middle and Information Tier

Integrating the Quotation page with your site

Multimedia im Netz Online Multimedia Winter semester 2015/16. Tutorial 07 Minor Subject

Form Validation (with jquery, HTML5, and CSS) MIS Konstantin Bauman. Department of MIS Fox School of Business Temple University

A conditional statement can compare two values. Here we check if one variable we declared is greater than another. It is true so the code executes.

Developing Apps for the BlackBerry PlayBook

DOM Primer Part 2. Contents

Ajax. David Matuszek's presentation,

Session 17. JavaScript Part 2. W3C DOM Reading and Reference. Background and introduction.

VALIDATING USING REGULAR EXPRESSIONS Understanding Regular Expression Characters:

Transcription:

Solutions to exercises Exercise textbox <title>greetings</title> Name: <input type="text" id="name"/> <input id="button" type="button" value="greet" /> <div id="result"> var button = document.getelementbyid("button"); button.onclick = clickgreet; function clickgreet() { var namefield = document.getelementbyid("name"); var name = namefield.value; var resultfield = document.getelementbyid("result"); var date = new Date(); var hour = date.gethours(); if (hour < 13) { resultfield.innerhtml = "Good morning, " + name; else { resultfield.innerhtml = "Good afternoon, " + name; Exdomcalculationwithselect.html "use strict"; function calculate() { var n1 = parseint(document.getelementbyid("n1").value); var n2 = parseint(document.getelementbyid("n2").value); var operator = document.getelementbyid("operator").value; var result = document.getelementbyid("result"); switch(operator) { case "+": result.textcontent = n1 + n2; case "/": result.textcontent = n1 / n2; case "*": result.textcontent = n1 * n2; case "-": result.textcontent = n1 - n2; Solutions JavaScript exercises(part 2) 1

<input type="text" id="n1"/> <select id="operator"> <option value="+">+</option> <option value="/">/</option> <option value="*">*</option> <option value="-">-</option> <input type="text" id="n2"/> <input id="btn" type="button" value="=" /> <span id="result"></span> var btn = document.getelementbyid("btn"); btn.onclick = calculate; Exercise Select <title>transfer names</title> <select id="left" size="4" style="float:left;width:70px"> <option value="john">john</option> <option value="paul">paul</option> <option value="ringo">ringo</option> <option value="george">george</option> <div style="float:left"> <input id="toright" type="button" disabled="true" value=">" style="display:block"/> <input id="toleft" type="button" disabled="true" value="<" style="display:block"/> <select id="right" size="4" style="float:left;width:70px"> function moveright() { var option = left.options[left.options.selectedindex]; right.options.add(option); left.options.remove(left.options.selectedindex); leftindexchanged(); rightindexchanged(); function moveleft() { var option = right.options[right.options.selectedindex]; left.options.add(option); right.options.remove(right.options.selectedindex); Solutions JavaScript exercises(part 2) 2

rightindexchanged(); leftindexchanged(); function leftindexchanged() { var toright = document.getelementbyid("toright"); if (left.options.selectedindex > -1){ toright.disabled = false; else { toright.disabled = true; function rightindexchanged() { var toleft = document.getelementbyid("toleft"); if (right.options.selectedindex > -1){ toleft.disabled = false; else { toleft.disabled = true; var toright = document.getelementbyid("toright"); var toleft = document.getelementbyid("toleft"); toright.onclick = moveright; toleft.onclick = moveleft; left.onchange = leftindexchanged; right.onchange = rightindexchanged; Solutions JavaScript exercises(part 2) 3

Exercise Google <title>search google</title> <style>.hideerror{ display:none;.showerror{ display:block; color:red; </style> <form id="frm" action="http://www.google.be/search" method="get"> <div><label for="q">search:</label> <input type="text" name="q" id="q" required/> <div> <label for="lr">language</label> <select name="lr" id="lr"> <option value="">all</option> <option value="lang_fr">french</option> <option value="lang_nl">dutch</option> <div> <label for="cr">country</label> <select name="cr" id="cr"> <option value="">all</option> <option value="countryfr">france</option> <option value="countrybe">belgium</option> <option value="countrynl">netherlands</option> <div id="error" class="hideerror">you cannot search for french pages in the Netherlands <input type="submit" value="submit"/> </form> "use strict"; var frm = document.getelementbyid("frm"); frm.onsubmit= function() { var selectlanguage = this.elements.nameditem("lr"); var selectcountry = this.elements.nameditem("cr"); var errordiv = document.getelementbyid("error"); console.dir(selectlanguage); console.dir(selectcountry); if (selectlanguage.value === "lang_fr" && selectcountry.value === "countrynl") { errordiv.classname = "showerror"; return false; Solutions JavaScript exercises(part 2) 4

return true; ; Solutions JavaScript exercises(part 2) 5