Conditions and More Web Form Fields. Conditions if (then) else Syntax if( ) Boolean expression { { } } instructions if expression is true (then) instructions.

Slides:



Advertisements
Similar presentations
Decision Structures - If / Else If / Else. Decisions Often we need to make decisions based on information that we receive. Often we need to make decisions.
Advertisements

Chapter 4 - Control Statements
Chapter 4 Decision Making Lecture Slides to Accompany An Introduction to Computer Science Using Java (2nd Edition) by S.N. Kamin, D. Mickunas, E. Reingold.
3-1 Chapter 3 Flow of Control (part a - branching)
CS201 – Introduction to Computing – Sabancı University 1 Conditional Execution – Sections 4.2, 4.3, 4.4 and 4.7 l Up to now, we have seen that instructions.
Making Decisions in Python Sec 9-10 Web Design. Objectives The student will: Understand how to make a decision in Python Understand the structure of an.
 2008 Pearson Education, Inc. All rights reserved JavaScript: Control Statements I.
1 9/24/07CS150 Introduction to Computer Science 1 Relational Operators and the If Statement.
Week 10 Recap CSE 115 Spring For-each loop When we have a collection and want to do something to all elements of that collection we use the for-each.
(c) 2003 E.S.Boese1 Conditionals Chapter 10 - Student.
3 November Building an Interactive Web Page: HTML Forms.
CSCI 116 Decisions & Validation. Overview Constants Boolean conditions Decision logic Form validation 2.
Lecture 11. Today’s topic Conditional statement –Relational operators –if statement –if-else statement –If-elseif statement.
Control Structures: Getting Started Sequence and Selection also arithmetic operators, data types, logical operators.
29 November JavaScript: Arrays and Iterations Functions.
Flow control 1: if-statements (Liang 72-80) if(radius < 0) { System.out.println(“cannot get area: radius below zero”); } else { double area = radius *
1 CS150 Introduction to Computer Science 1 Relational Operators and the If Statement 9/22/08.
Programming with MATLAB. Relational Operators The arithmetic operators has precedence over relational operators.
JavaScript Form Validation
4-Sep-15 HTML Forms Mrs. Goins Web Design Class. Parts of a Web Form A Form is an area that can contain Form Control/Elements. Each piece of information.
Engineering 1020 Introduction to Programming Peter King Winter 2010.
CHAPTER 4: CONDITIONAL STRUCTURES Introduction to Computer Science Using Ruby (c) 2012 Ophir Frieder et al.
PAGES:51-59 SECTION: CONTROL1 : DECISIONS Decisions.
1. We’ve learned that our programs are read by the compiler in order, from top to bottom, just as they are written The order of statement execution is.
Using Client-Side Scripts to Enhance Web Applications 1.
MS3304: Week 6 Conditional statements. Overview The flow of control through a script Boolean Logic Conditional & logical operators Basic decision making.
If…else statements. Boolean Expressions Boolean expression - An expression whose value is either true or false true = 1 false = 0 Datatype: boolean.
Conditional Expression One of the most useful tools for processing information in an event procedure is a conditional expression. A conditional expression.
HTML Forms a form is a container for input elements on a web page input elements contain data that is sent to the web server for processing.
Iteration Chapter Iteration = Repetition 3 Looping Via The for Loop for loop: A block of code that executes a group of statements repeatedly until.
PEG200/Saidatul Rahah 1.  Selection Criteria › if..else statement › relational operators › logical operators  The if-then-else Statement  Nested if.
Decisions. Three Forms of Decision Making in Java if statements (test a boolean expression) switch statements (test an integer expression) conditional.
CS 240 – Computer Programming I Lab Kalpa Gunaratna –
Control statements Mostafa Abdallah
Web Forms and Calculations in JavaScript. Web Forms.
Lesson thirteen Conditional Statement "if- else" ©
Computer Science 101 If Statement. Python Relational Operators.
CheckBox i Option Button. Private Sub Command1_Click() Check1 = 1 If Check1 = 1 Then Text1.FontBold = True Else Text1.FontBold = False End If Check2 =
Knowledge Base. Defining a Variable Dim statement Dim intXX As Integer Public in a Module Public dblNN As Double.
Check Boxes. 2 Check boxes  Image from:  HTML:  Each box gets it's own.
Conditional statements and boolean expressions Arithmetic, relational and logical operators.
Control Flow (Python) Dr. José M. Reyes Álamo. 2 Control Flow Sequential statements Decision statements Repetition statements (loops)
Control Flow (Python) Dr. José M. Reyes Álamo. 2 Control Flow Sequential statements Decision statements Repetition statements (loops)
Silberschatz and Galvin  C Programming Language Decision making in C Kingdom of Saudi Arabia Ministry of Higher Education Al-Majma’ah University.
IF STATEMENTS AND BOOLEAN EXPRESSIONS. BOOLEAN EXPRESSIONS Evaluate to a value of true or false Use relational or equivalence operators Boolean operators.
 Type Called bool  Bool has only two possible values: True and False.
Computer Science 1000 LOGO II. Boolean Expressions like Excel and Scratch, LOGO supports three Boolean operators less than (
Control Flow (Python) Dr. José M. Reyes Álamo.
Making Choices with if Statements
Sequence, Selection, Iteration The IF Statement
C-Language Lecture By B.S.S.Tejesh, S.Neeraja
>> Form Data Retrieval in JavaScript
Programming the Web using XHTML and JavaScript
Chapter 6: Conditional Statements and Loops
HTML/XHTML Forms 18-Sep-18.
Introduction to MATLAB
And the text with form..
JavaScript Selection Statement Creating Array
JavaScript conditional
Conditions and Ifs BIS1523 – Lecture 8.
CSE 1020:Control Structure
Selection Statements.
If Statements.
Conditional Logic Presentation Name Course Name
Understanding Conditions
CS2011 Introduction to Programming I Selections (I)
Relational Operators.
Working with ‘checked’ items Checkboxes and Radio buttons
Lecture 9: Implementing Complex Logic
Conditionals.
Presentation transcript:

Conditions and More Web Form Fields

Conditions

if (then) else Syntax if( ) Boolean expression { { } } instructions if expression is true (then) instructions if expression is false else

Example Check age < 59 >65 Gotta Work!Retire! >=59 and <65 Early Retirement?

Example – Step 1 if()age < 59 { } alert(‘Gotta Work!’)

Example – Step 2 if()age < 59 { { } } alert(‘Gotta Work!’) else { } alert(‘Early Retirement?’) if()age >= 59 && age < 65 (age >= 59) && (age < 65)

Example – Step 2 (v2) if()age < 59 { } alert(‘Gotta Work!’) else if()(age >= 59) && (age < 65) { } alert(‘Early Retirement?’)

Example – Step 3 if()age < 59 { } alert(‘Gotta Work!’) else if()(age >= 59) && (age < 65) { } alert(‘Early Retirement?’) else { } alert(‘Retire!’)

Example – Step 3 (v2) if()age < 59 { } alert(‘Gotta Work!’) else if()(age >= 59) && (age < 65) { } alert(‘Early Retirement?’) else { } alert(‘Retire!’)

Relational Operators == Equal to >Greater than <Less than >=Greater than or equal to <=Less than or equal to !=Not equal to

Danger Will Robinson function check(p) { var a = p alert('initial a = ' + a) if (a = 5) { alert('if a = 5') } alert('final a = ' + a) } check(10) initial a = 10 if a = 5 final a = 5 a == 5 JavaScript assignment statements execute and evaluate to true.

Expressions and Conditions if()(age >= 59) && (age < 65) Boolean Expression Condition 1Condition 2

AND and OR AND&& Both conditions true  expression is true. Otherwise expression is false. if (condition1 && condition2) OR|| Either condition true  expression is true. if (condition1 || condition2)

More Web Form Fields

Checkbox <input type="checkbox" name="student" checked="checked" />

Checkbox document.getstuff.student.checked...documentformfieldchecked Boolean true or false

Radio Button <input type="radio" name="sex" Id="female" value="F" /> <input type="radio" name="sex" id="male" value="M" /> Gender: Male Female Index = 0 Index = 1

var message var indx message = ‘by Index using Checked property\n‘ for (indx = 0; indx < document.getstuff.sex.length; indx++) { message = message + 'Indx=' + indx + ' checked=' + document.getstuff.sex[indx].checked + '\n‘ } alert(message)

message = ‘by Index using Value property\n‘ for (indx = 0; indx < document.getstuff.sex.length; indx++) { message = message + 'Indx=' + indx + ' value=' + document.getstuff.sex[indx].value + '\n‘ } alert(message)

message = ‘by d.f.id.checked\n‘ message = message + 'document.getstuff.male.checked=' + document.getstuff.male.checked + '\n‘ message = message + 'document.getstuff.female.checked=' + document.getstuff.female.checked + '\n‘ alert(message)

Select and Option Management Information Systems Computer Information Systems Information Security and Privacy

Select and Option document.getstuff.major.value..documentformfieldvalue. Management Information Systems Computer Information Systems Information Security and Privacy