8 november n.
Download
Skip this Video
Loading SlideShow in 5 Seconds..
8 November PowerPoint Presentation
Download Presentation
8 November

Loading in 2 Seconds...

play fullscreen
1 / 28

8 November - PowerPoint PPT Presentation


  • 128 Views
  • Uploaded on

8 November. Forms and JavaScript. Types of Inputs. Radio Buttons (select one of a list) Checkbox (select as many as wanted) Text inputs (user types text) Select List (select from a list) Buttons (click on or off). Select List. Syntax <select name=“name for this list”

loader
I am the owner, or an agent authorized to act on behalf of the owner, of the copyrighted work described.
capcha
Download Presentation

PowerPoint Slideshow about '8 November' - nizana


An Image/Link below is provided (as is) to download presentation

Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author.While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server.


- - - - - - - - - - - - - - - - - - - - - - - - - - E N D - - - - - - - - - - - - - - - - - - - - - - - - - -
Presentation Transcript
8 november

8 November

Forms and JavaScript

types of inputs
Types of Inputs
  • Radio Buttons (select one of a list)
  • Checkbox (select as many as wanted)
  • Text inputs (user types text)
  • Select List (select from a list)
  • Buttons (click on or off)
select list
Select List
  • Syntax

<select name=“name for this list”

size=“number-of-entries-to-show”>

<option value=“value-to-be-stored” [selected=”selected”]>

Text to be displayed

</option>

</select>

  • What it does
    • Lets the user select one entry from a list of fixed text
      • (extension to select multiples)
    • Optional initial value
    • Displayed text part of tags
    • Scroll bar built in
  • How it does it
    • Own variable
    • Value is the selected entry
buttons
Buttons
  • Syntax

<input type=“button”

value=“name to be displayed”

onclick=“what to do when the button is clicked”>

  • What it does
    • Lets you perform an action
      • Need to learn a little Javascript
    • Lots of different events (e.g., mouseover), but we’ll only worry about “onclick”
writing a program
Writing a Program
  • Want to be able to describe a program in human comprehensible terms
  • Programs translates from those terms to machine comprehensible
  • Same precision is needed, but do not worry about
    • where in the computer information is stored
    • what instructions look like
  • What you write is referred to as code
executing a program
Executing a Program
  • Two types of translators
    • compiler and interpreter
  • Compiler creates a program that can be stored and run later without the compiler
  • Interpreter follows the instructions that are described and is always used when running the program
  • Writing a program is basically the same in either case
to write a program
To write a program
  • Basically two parts: the information and what to do with it
  • Identify the data that you are going to use
  • Describe what to do with the data: the algorithm
example calculator
Example: Calculator
  • Data
    • The numbers that are going to be processed
    • The result
    • Memory holders
  • What to do with it
    • Compute the requested functions
    • Display the results
example sales
Example: Sales
  • Data
    • The items for sale: name, cost
    • The person buying: name, address, credit card information
    • The actual order: quantity of each item purchased
  • What to do with it
    • Compute the cost
    • Display the current order
general javascript rules
General JavaScript Rules
  • Case-sensitive
    • Taxrate, TaxRate, and taxrate are all different!
  • Uses ; to end statements
    • Similar to a period in English
    • Unlike people, computers can get confused if you forget it
creating a variable
Creating a Variable
  • Review:
    • Computers store values in memory
      • Refer to the place, not the value
    • The location is referred to as a variable
    • A variable’s name is called an identifier
  • Need to tell computer
    • The name that you are going to use
    • What value it starts with
  • How to interpret the bits: the type of data
    • Some language require that you tell it
    • Some deduce it based on what you assign to it
    • Some permit either (JavaScript)
types of data javascript
Types of Data (JavaScript)
  • Numbers
    • Integers
    • Floating point numbers
  • Strings
  • Booleans
representing integers
Representing Integers
  • Additive system
    • lllll lllll
    • Every item represents 1
    • Examples of additive systems?
  • Positional system
    • Value = face * place
    • 37 = 3*10 + 7*1
positional system
Positional System
  • Base = number of different values in a position
    • Base 10 = 10 values: 0-9
    • Base 2 = 2 values: 0-1
  • Value of each position = power of base
    • b4 b3 b2 b1 b0
example in base 2
Example in Base 2

1010= 1 x 23 + 0 x 22 + 1 x 21 + 0 x 20

1 x 8 + 0 x 4 + 1 x 2 + 0 x 1

8 + 0 +2 + 0

8 + 2

10

integers
Integers
  • What information is needed?
  • Sign and magnitude
  • We use sign-magnitude notation
    • +1, -1
  • Machine arithmetic is harder this way
how integers are stored
How Integers are Stored
  • Two’s complement
    • We’re not going to look at how it works in detail, but there important characteristics:
      • Maximum value that can be stored
      • If checking is not done correctly, positive numbers that are too big will appear to be negative numbers
example
Example
  • Assume that we only have 4 bits to work with
    • Largest positive number is 7 = 0111
  • Adding 1 to that number
    • 0111
    • + 1
    • 1000
  • Turns out that is the representation for the largest negative number (-8)
why do you care
Why Do You Care?
  • Properly working program: message that says that the number is too large
  • Erroneous program: you get a negative number when you expect a positive one
floating point numbers
Floating Point Numbers
  • Scientific notation
    • 1.452 x 1017

Mantissa exponent

  • Need to store larger numbers than possible in integers
    • Use sign magnitude: high order bit = sign
    • Then store exponent and mantissa
    • Can be single or double word
      • Precision of the number
ieee floating point standard single precision
IEEE Floating Point Standard(Single Precision)
  • The Sign Bit (1 bit)
    • 0 denotes a positive number; 1 denotes a negative number
  • The Exponent (8 bits)
    • Needs to represent both positive and negative exponents
    • Add a bias of 127. Subtract 127 to see the real exponent
  • The Mantissa (23 bits)
    • Implicit leading bit of 1 and the fraction bits
    • Adjust the value so that the leading bit is 1, then drop it.
      • Example: 5.00 x 100 = 0.05 x 102 = 5000 x 10-3
      • In binary 101 x 100 = 1.01 x 102
    • Decimal point is to the left of the stored number (normalized form)
  • 5 = 1 10000001 01000000000000000000000
floating point errors
Floating Point: Errors
  • In decimal, 1/3 can’t be represented as a fixed decimal number
  • Lots of examples in binary as well
  • Problems occur
    • Converting between integer and floating point
    • Displaying results

Whittaker, How to Break Software

slide24
Text
  • Need to represent characters
    • All data in the computer is stored as _____
    • Letter a question of interpretation
    • Also includes some control: new line, tab, …
    • Not font
  • Representations
    • ASCII, EBCDIC, UNICODE, …
    • ASCII simplest
valuable characteristics
Valuable Characteristics
  • Collating sequence
  • Simple upper/lower case
  • Support of all languages
  • Other?
ascii collating
ASCII collating
  • For collating sequence, where should punctuation be?
  • General rule:
    • space < punctuation < number < letter
  • How to deal with case?
    • Collating sequence is case insensitive
  • Need to force to uppercase
multiple languages
Multiple languages
  • Used to have complete different set of encodings for each language, called code pages
  • Unicode is fundamentally 2-bytes
    • Preserves the ASCII values
    • Doubles the size of files
  • www.unicode.org
boolean
Boolean
  • Two values: true or false