Login | Register   
LinkedIn
Google+
Twitter
RSS Feed
Download our iPhone app
TODAY'S HEADLINES  |   ARTICLE ARCHIVE  |   FORUMS  |   TIP BANK
Browse DevX
Sign up for e-mail newsletters from DevX


advertisement
 

More Useful Form-Building Routines  : Page 3

Use automatic control-building routines to create and populate HTML combo and list box controls from a database.


advertisement

Adding Client Side Validation

   If blnRequired Then
      mstrFormValidationScript = _
      mstrFormValidationScript & _
      "if(f." & strFieldName & ".value=="""") {" & _
         vbCrLf & _
      "   msg += 'Please select a value for the \'" & _
         strLabel & "\' field.\n';" & vbCrLf & _
      "   retVal = false;" & vbCrLf & _
      "}" & vbCrLf & vbCrLf 
   End If   
Because the "value" of the first item in the list is a null string, this client side validation checks to see if the value of the combo box is a blank string. If so, it flags an error that will be captured when the form is submitted.

And there you have it. A single line call will access the database and populate a combo box with values. To modify the code to build a list box instead of a combo box, you can simply copy the DisplayComboBox routine and call it DisplayListBox. All it needs is a new argument to specify the size in items of your list box and a change in the line:

      ' -- Output the select tag
      Response.Write "<SELECT NAME=""" & _
         strFieldName & """ SIZE=""1"" >"
Change the "SIZE=1" value to a "SIZE=N" value where N is an argument you pass.


Comment and Contribute

 

 

 

 

 


(Maximum characters: 1200). You have 1200 characters left.

 

 

Sitemap
Thanks for your registration, follow us on our social networks to keep up-to-date