alittle advanced, please help

Results 1 to 2 of 2

Thread: alittle advanced, please help

  1. #1 Guest

    Default alittle advanced, please help

    I have a dynamic form built from a database tbl of questions.<BR>User enters information into form and submits.<BR>I send <BR>text=email value=userentered <BR>under that I have<BR>hidden=email value=required<BR><BR>This gives me the email value the user entered and tells me that <BR>the email is required.<BR>I&#039m looking for the most productive way to do the following.<BR><BR>1)I want to separate the data into an array, remember the form is dynamic so I never know how many fields are coming until I do a count and I DO know if they are required.<BR>2)if a field is required then make sure its been entered by user<BR>3)enter the info into a database(dynamic sql statement)<BR>if you can help please do so, I&#039m stuck

  2. #2
    Join Date
    Dec 1969

    Default RE: alittle advanced, please help

    I think I have an easier way to accomplish this.<BR><BR>*ALWAYS* output the HIDDEN field that describes the non-hidden field, even if you aren&#039t describing a required field. If nothing else, you could *also* use the value of the hidden field to indicate any appropriate validations to be performed on the user-entered data---such as looking for valid dates in date fields, well-formed email addresses, etc. Whether you use the validation info on client or server side is up to you.<BR><BR> *also* give the Hidden fields the same names as the corresponding non-hidden names *except* you prefix them with some special character or two. Maybe just a $ would work.<BR><BR>Now, on the page that gets submitted to, you simply do:<BR><BR>&#060;%<BR>For Each Item In Request.Form<BR>&nbsp;&nbsp;&nbsp;&nbsp;If Left(Item,1) = "$" Then <BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbs p;&#039 you know this is a hidden field that describes a non-hidden<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbs p;&nbsp;&#039 field with parallel name...<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nb sp;&nbsp;nonHiddenName = Mid(Item,2)<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp ;&nbsp;&nbsp;nonHiddenValue = Request.Form(nonHiddenName)<BR>&nbsp;&nbsp;&nbsp;& nbsp;&nbsp;&nbsp;&nbsp;&nbsp;hiddenValue = Request.Form(hiddenName)<BR>&nbsp;&nbsp;&nbsp;&nbs p;&nbsp;&nbsp;&nbsp;&nbsp;... and now you have all you need ...<BR>&nbsp;&nbsp;&nbsp;&nbsp;End If<BR>Next<BR>%&#062;<BR><BR>Your code just follows the "instructions" that you placed in the hidden field about how to manage/validate/whatever the non-hidden field.<BR><BR>**********************<BR><BR>ALTERN ATIVE: If you will do *all* your validation on the client (e.g., using JavaScript), then you can omit the hidden fields. Instead, just encode the needed information in the *NAME* of each field, perhaps as a suffix to the ordinary field name and separated by a special character (e.g., $).<BR><BR>SO...<BR><BR>&#060;FORM ...&#062;<BR>&#060;INPUT Type="Text" Name="EMail$RE"&#062;<BR><BR>And the "R" in that suffix means "Required" and the "E" means "validate as an email address".<BR><BR>Any your JS code:<BR><BR>&#060;SCRIPT Language=JavaScript&#062;<BR>function validateForm( whichForm )<BR>{<BR>&nbsp;&nbsp;&nbsp;&nbsp;for( fld in whichForm.elements )<BR>&nbsp;&nbsp;&nbsp;&nbsp;{<BR>&nbsp;&nbsp;&nbs p;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;fldName =;<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;& nbsp;&nbsp;flags = fldName.substring( fldName.charAt(&#039$&#039)+1 )<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nb sp;... at this point "flags" contains "RE" ....<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;... assuming that the field name is "EMail$RE" ...<BR>&nbsp;&nbsp;&nbsp;&nbsp;}<BR>&nbsp;&nbsp;&n bsp;&nbsp;...<BR>}<BR><BR>SO...lots of ways. Lots of ideas. I guess you just have to choose what makes you most comfortable and looks easy (to you) to implement.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts