dcsimg

Lesson 31: The Script and Its Effect



The Script

<SCRIPT LANGUAGE="javascript">
function figureItOut()
{
var dinCost = document.meal.dinner.value
var tipCost = dinCost * .15
var bigtipCost = dinCost * .25

document.meal.tip.value = tipCost
document.meal.bigtip.value = bigtipCost

}
</SCRIPT>


How much was dinner? $<INPUT TYPE="text" NAME="dinner">

<INPUT TYPE="button" VALUE = "OK, Hit Me!" onClick="figureItOut()">

You should tip: $<INPUT TYPE="text" NAME="tip">
A big tipper would leave 25% $<INPUT TYPE="text" NAME="bigtip">
</FORM>

 

The Script's Effect

How much was dinner? $

You should tip: $
A big tipper would leave 25% $

 

Back to the Index Page