JS Learning-Incident Response summary-Simple calculator

Source: Internet
Author: User

<!DOCTYPE HTML><HTML> <Head>  <title>Event</title>    <Scripttype= "Text/javascript">   functioncount () {varFnum=document.getElementById ("txt1"). Value;//gets the value of the first input box        varSnum=document.getElementById ("txt2"). Value;//gets the value of the second input box        varsel=document.getElementById ("Select"). Value//gets the value of the selection box        varsum=0; Switch(SEL) {//gets the value selected by the drop-down box to change the subtraction algorithm             Case "+": Sum=parsefloat (fnum)+parsefloat (snum);//Value values obtained by getElementById by default to String type                 Break;  Case "-": Sum=Fnum-Snum;  Break;  Case "*": Sum=Fnum*Snum;  Break; default: Sum=Fnum/Snum;                 Break; }    //set the value of the result input boxdocument.getElementById ("Fruit"). Value=sum; }  </Script>  </Head>  <Body>   <inputtype= ' text 'ID= ' Txt1 '/>    <SelectID= ' SELECT '>        <optionvalue= ' + '>+</option>        <optionvalue="-">-</option>        <optionvalue="*">*</option>        <optionvalue="/">/</option>   </Select>   <inputtype= ' text 'ID= ' txt2 '/>    <inputtype= ' button 'value= ' = 'onclick= ' count () '/> <!--Use the = button to invoke the created function to get the result -    <inputtype= ' text 'ID= ' Fruit '/>    </Body></HTML>

Ability to implement basic arithmetic operations, a selection box, two text boxes, a button

Main Event Response:

    1. OnClick mouse click event (usually used with the button)
    2. onmouseover Mouse over events (commonly used for hints)
    3. onmouseout Mouse Move Event
    4. onchange text Box content Change Event
    5. Onselect text box content is selected event
    6. onfocus Cursor Focus Event
    7. onblur Cursor Leave event
    8. OnLoad Load event (the OnLoad event is triggered when the page is loaded, and the event is written in the <body> tab.) Write which to listen to which. )
    9. OnUnload Unload event (when the user exits the page, such as the page close "close refers to the page jump", the refresh is triggered)

The effect of the OnLoad event:

Loading events can be used to adjust the page style by JS code before the page is loaded, for example, after detecting the browser width screen resolution, adjust the corresponding size of the page

JS Learning-Incident Response summary-Simple calculator

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.