![]() | ||||||||||||||||||||||||||||||||||||||||||||
![]()
Gallery Software Data Files Reference: HTML Tags Appendix D: JavaScript Objects, Properties, Methods, Event Handlers Appendix E: JavaScript Operators, Elements, Keywords Appendix F: Cascading Style Sheets | Programming with | |||||||||||||||||||||||||||||||||||||||||||
JavaScript Resources on the Web |
If you want more information on using JavaScript, here are some resources on the Web:
Ask the JavaScript Pro
variable = (condition) ? value1 : value2; where variable is the variable name, condition is a conditional expression that is either true or false, value1 is the value of the variable if the condition is true, and value2 is the value if the condition is false. For example, the following JavaScript command: Days = (Month=="Feb") ? "< 30" : ">= 30"; The variable Days will be equal to "< 30" if the Month variable is "Feb", otherwise it will be equal to ">= 30".
The break command halts the loop, even if the conditions to the end the loop have not been met. For example, if you want to create a loop that prompts students to answer a question, and give them three chances to answer that question, you can use the following JavaScript program:
for (i=1;i<=3;i++) { In this example, if the answer variable is equal to "1861" (the correct answer) the loop stops with the break command. If the student answers the question incorrectly, the loop continues for 3 iterations or until the question is answered correctly (note that you can learn more about the alert() and prompt() methods in Tutorial 8.) To see this JavaScript program in action, click the button below:
<SCRIPT> Here is the output from that script: Be not afraid: the isle is full of noises, sounds and sweet airs that give delight and hurt not. Sometimes a thousand twangling instruments will hum about mine ears; and sometime voices that, if I then had waked after long sleep will make me sleep again; and then, in dreaming, the clouds methought would open and show riches ready to drop upon me, that, when I waked, I cried to dream again. Notice that by using the += operator, you've created a text string much longer than the length of a single line.
| ||||||||||||||||||||||||||||||||||||
| Website design by SKDesigns. |