Forum

HomeHomeCoreCoreSamples and oth...Samples and oth...Iterate through form fieldsIterate through form fields
Previous
 
Next
New Post
8/9/2010 12:09 AM
 

How can I iterate through incoming form fields? I can list all the fields and values that are being posted to the page using [Request.Form] and count the number of fields with [Request.Form.Count] but can't quite figure out how to pull the names of the fileds using a key. Or pull all the field names and values by looping through the [Request.Form]

Thanks for the help.

-Jeff

New Post
7/30/2011 9:28 AM
 

 Did you ever get an answer or figure out how to iterate through the form collection?  That would be super useful for an application I am trying to build in open web studio.  Any tips would be greatly appreciated.

 

Thanks

New Post
7/30/2011 9:39 AM
 

The problem with iterating through [Request.Form] is that DNN has a lot of form values that gets passed along as well as your form. What I have done is create a small jQuery script that iterates through my form and puts the field names in a hidden text field, then I can use that field to iterate through the form values of my form.

<div id="form_validate" class="FormBox">***MY FORM***</div>
<div><input type="hidden" name="formFields" id="formFields" /></div>
<script>
var formFields = $(".FormBox :input").map(function(){
      return $(this).attr('name');
    }).get().join(", ")
$('#formFields').val(formFields);
 
</script>
 

So the value of the formFields will be something like: Firstname,Lastname,Email,Phone (ie, the field names in a comma delimited format).

New Post
7/30/2011 10:27 AM
 

Ok, thanks for the reply. That totally works to grab the form field names.  

Being new to OWS I am trying to get my head around this.  Now i'm tuck trying to create a loop that will parse the delimited list and allow access to request.form[formitem].

My formFields contains this- this is a dynamic list

formFields: frmIsDone_3_1, frmDescriptionText__31, frmReminderDate_3_1, frmDueDate_3_1, frmIsDone_3_2, frmDescriptionText__32, frmReminderDate_3_2, frmDueDate_3_2, frmIsDone_3_3, frmDescriptionText__33, frmReminderDate_3_3, frmDueDate_3_3, frmIsDone_3_4, frmDescriptionText__34, frmReminderDate_3_4, frmDueDate_3_4, frmIsDone_3_5, frmDescriptionText__35, frmReminderDate_3_5, frmDueDate_3_5, frmIsDone_3_6, frmDescriptionText__36, frmReminderDate_3_6, frmDueDate_3_6, frmIsDone_3_7, frmDescriptionText__37, frmReminderDate_3_7, frmDueDate_3_7, frmIsDone_3_8, frmDescriptionText__38, frmReminderDate_3_8, frmDueDate_3_8, frmIsDone_3_9, frmDescriptionText__39, frmReminderDate_3_9, frmDueDate_3_9

How can this loop be setup to iterate through the delimited values in formFields?  

 

Is this a loop or an action query? How would I pass the dynamic item from the loop/query into the request.form/assign it to a variable in the loop?

 

Thanks

New Post
7/30/2011 11:19 AM
 

Run the attached file in a SQL query to create the function SplitText

Then: 

Create a variable,Type: Form,  Source:formFields  Value: @formFields

Create a named query  "formData"  query: Select * from SplitText(1,@formFields,',')

The result will be each field split up into rows so that you can run actions agaist each field.

 

 SplitText.txt
Previous
 
Next
HomeHomeCoreCoreSamples and oth...Samples and oth...Iterate through form fieldsIterate through form fields


 

New York, NY • Baltimore, MD • Vienna, VA • St. Louis, MO • Seatle, WA • 410.327.0007 • info@R2Integrated.com

Bookmark & Share Bookmark and Share