stuart-d2
3/7/2016 - 5:15 PM

Typical Web Page Jscript Wire Up I/O ABC

Typical Web Page Jscript Wire Up I/O ABC


//WIRING A FUNCITON TO A UI ELEMENT : 
	//• Conceptually 
	//	A. User Input to Trigger to Function Execution
	//	B. Function Execution
	//	C. Output 


    <!DOCTYPE html>
    <html>
    <body>
    
    <p>Click the button to get a time-based greeting:</p>

//A.  INPUT : wire to a element onclick
<button onclick="myFunction()">Try it</button>

//C2. OUTPUT : to the Innerhtml of a html element.  
<p id="demo"></p>

//B. FUNCTION : Funciton Triggered in script by user interaction.  
<script>
function myFunction() {
    var greeting;
    var time = new Date().getHours();
    if (time < 10) {
        greeting = "Good morning";
    } else if (time < 20) {
        greeting = "Good day";
    } else {
        greeting = "Good evening";
    }
////C1. OUTPUT : to the Innerhtml of a html element.  
document.getElementById("demo").innerHTML = greeting;
}
</script>

</body>
</html>