CSCE 102 General Application Programming Section 1,2,3 - PowerPoint PPT Presentation

1 / 8
About This Presentation
Title:

CSCE 102 General Application Programming Section 1,2,3

Description:

The input / tag allows for several different types of interaction with the web ... conv.color1.value)' type=button value='Click to change colors' name=convert ... – PowerPoint PPT presentation

Number of Views:40
Avg rating:3.0/5.0
Slides: 9
Provided by: JJ1
Category:

less

Transcript and Presenter's Notes

Title: CSCE 102 General Application Programming Section 1,2,3


1
CSCE 102 General Application ProgrammingSection
1,2,3
  • Instructor Jin Jin
  • jinj_at_cse.sc.edu

2
Textbox
  • ltform idformName nameformNamegt
  • ltinput typetext idInputBox1
    nameInputBox1 valueInput1 size20 /gt
  • ltbr /gt
  • ltinput typetext idInputBox2
    nameInputBox2 valueInput2 size20 /gt
  • lt/formgt
  • The ltinput /gt tag allows for several different
    types of interaction with the web surfer, such as
    buttons, textbox and radiobuttons which we will
    cover shortly in class.
  • typetext creates a text box
  • name the name of the textbox
  • size the width of the textbox displayed in the
    browser.

3
Textbox
  • Retrieve the value we entered in the textbox
  • document.formName.InputBox1.value
  • document.formName.InputBox2.value
  • object.object.object.property
  • ltform idconv nameconvgt
  • ltinput idcolor1 size30 typetext
  • value"Enter background color here" namecolor1
    /gt
  • ltinput idconvert
  • onclick"changeColors(document.conv.color1.value)"
    typebutton value"Click to change colors"
    nameconvertgt
  • lt/FORMgt

4
Textbox
  • ltscript type"text/javascript"gt
  • function changeColors(color)
  • document.body.style.color color
  • lt/scriptgt

5
Textbox
  • Retrieve the value we entered in the textbox
    contd

6
Performing Calculations Basics
  • Basic math with Javascript
  • Mathematical operators -, , /
  • Example
  • var theResult, anotherResult, result3
  • theResult5.14.6-3
  • anotherResult73
  • Result324/6
  • ----------------------------
  • var theResult, anotherResult, result3
  • theResult5.14.6-3
  • anotherResult73theResult
  • Result3theResult/10-anotherResult

7
Performing Calculations Basics
  • Example contd
  • var firstNum, secondNum, theResult
  • firstNum12
  • secondNum7
  • theResultfirstNumsecondNum
  • firstNum10
  • alert(The value of theResult is theResult)
  • Precedence of Operations

8
Performing Calculations Basics
  • Math.sqrt(25) take the square root of the number
  • Math.round(4.49) round the number to the nearest
    integer
  • Math.floor(4.99) get rid of the decimal digits
    without rounding
Write a Comment
User Comments (0)
About PowerShow.com