Link to home
Start Free TrialLog in
Avatar of lambsan
lambsan

asked on

client side vbScript formcheck for multiple select box

I need to put the following javascript fromcheck into client side vbscript and I'm not sure of the syntex.
Basically the code needs to check that not more than 10 keywords have been selected before the form can be posted

for(i=0;i<document.form1.Keywords.length;i++)            
{      
  if(document.form1.Keywords[i].selected) iCount++;
             }
   if(iCount > 10)
              {
   mess = mess + "\nA maximum of 10 keywords";
            }    

}

Thanks
ASKER CERTIFIED SOLUTION
Avatar of KAbbott
KAbbott
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of lambsan
lambsan

ASKER

Thanks for that,
Unfortunetly I don't think I can use this technique, as I'm using a clientside vbscript function to assign permissions to network folders but beofre I call this function, I need to check the form, both need to run before the form is submitted.

For Each strUser in Document.VolumeDetails.AssignUser
     MsgBox "Selected Users:" & Document.VolumeDetails.AssignUser.Value
     
Next
 I've put this together but it displays the message box for every item in the list (not every selected item) and then it just shows the first selected item,
Its driving me mad!

Avatar of lambsan

ASKER

Thanks for that,
Unfortunetly I don't think I can use this technique, as I'm using a clientside vbscript function to assign permissions to network folders but beofre I call this function, I need to check the form, both need to run before the form is submitted.

For Each strUser in Document.VolumeDetails.AssignUser
     MsgBox "Selected Users:" & Document.VolumeDetails.AssignUser.Value
     
Next
 I've put this together but it displays the message box for every item in the list (not every selected item) and then it just shows the first selected item,
Its driving me mad!

Avatar of lambsan

ASKER

Thanks for your suggestion,
I finally figured it out which is below in case anyone ever needs it

For Each objKeyword in TheForm.Keywords
     If objKeyword.selected Then
          i = i + 1
     End If
Next
If i > 10 Then
     strMessage = strMessage &  vbcrlf & "    -  A maximum of 10 Keywords"
     blnDataMissing = True
End If