
Skype: beeworkweb
Email:info@beework.net
Sales (free):
0800 882 4173
Support:
0870 978 0583
Mobile:
07866 627185
Registered Member
of the UK Web Design
Association
Generates JavaScript for do loop code. Specify the number of times to create the loop and click Generate Code.
for ([initial-expression]; [condition]; [increment-expression]) {
statements
}When a for loop executes, the following occurs: <SCRIPT>
function howMany(selectObject) {
var numberSelected=0
for (var i=0; i < selectObject.options.length; i++) {
if (selectObject.options[i].selected==true)
numberSelected++
}
return numberSelected
}
</SCRIPT>
<FORM NAME="selectForm">
<P><B>Choose some music types, then click the button below:</B>
<BR><SELECT NAME="musicTypes" MULTIPLE>
<OPTION SELECTED> R&B
<OPTION> Jazz
<OPTION> Blues
<OPTION> New Age
<OPTION> Classical
<OPTION> Opera
</SELECT>
<P><INPUT TYPE="button" VALUE="How many are selected?"
onClick="alert ('Number of options selected: '
+ howMany(document.selectForm.musicTypes))">
</FORM>