#!/usr/local/bin/php
Here are the answers to the JavaScript exercises in the previous sections.
|
<script language="JavaScript"> |
I was born document.write(thisYear - 1985) |
I was born years ago. |
this.value
, and calculate the year when you will be that age. Use the method window.alert('string')
to display the result.<form> |
function c2name(column) { <form name="check"> <input type="button" name ="Check" value="Check" onClick="txtSheet = document.createTextNode(mySheet); </form> |
|
A more complete answer would track multiple displays of the spreadsheet, and when one is changed update the forms in the others.
The power-of-ten exponent of the number can be used as an index into a string to find the appropriate abbreviation:
abbrevLetter = "y..z..a..f..p..n..µ..mcd.DHK..M..G..T..P..E..Z..Y"
<script language="JavaScript">
|
Write a constructor for a "planet" object, and use it to create ten objects that store the planetary information on this web page:
http://www.opencourse.info/astronomy/introduction/05.motion_planets/#sidereal%20period http://www.opencourse.info/astronomy/introduction/05.motion_planets/#aphelion
Use the Sun as the first, with all values set to zero.
Write a web form that has a radio button input, one for each planet, and that onChange writes out the planet's information.
Why might it be a good idea to use PHP as part of this exercise?
The form provides the name of the planet, which can be used in an associative array to reference the planet's information. Its data is written into a textarea field, which allows more than one line of text.
Written strictly in JavaScript, the form can be implemented as follows:
<script language="JavaScript">
|
Note that some of this material is highly repetitious, varying only in small details. PHP can be useful to "loop through" this material, providing a more compact representation, especially with larger quantities of data (which might also be loaded from a file).
Written with PHP, the form can be implemented as follows:
<script language="JavaScript"> |
Write a form and button combination that, "onClick", activates the window method
window.alert('A string of your choice')
<form name="announce"> |
Write a JavaScript that outputs the browser version type, using the object property
navigator.appVersion
<script language="JavaScript"> |