• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 515
  • Last Modified:

Using jquery-dynamic-form and need to submit specific field names

form is here: http://aeronautical.com/members/form-test/

I'm using jquery-dynamic-form. It is renaming my fields which is then messing up my data submission.

What I would like to do is take the renamed fields, concatenate them together with a |  between each value and submit using the original field name.

So for instance, the first field in the first row is renamed to "parts[parts][0][part_numbers]" by jquery dynamic form. The original field name is simply part_numbers. As more parts are added I'd like to be creating a new field that will hold the concatenated value.

part_numbers=parts[parts][0][part_numbers]+"|"parts[parts][1][part_numbers]

How can I accomplish this? Right now jquery dyanmic forms is renaming any field so I can't even create a hidden input field named "part_numbers".

thanks for any assistance.
0
befidled
Asked:
befidled
  • 7
  • 2
1 Solution
 
leakim971PluritechnicianCommented:
0
 
leakim971PluritechnicianCommented:
You may use :http://api.jquery.com/serializeArray/
part_numbers = "";
$.map( $("form").serializeArray(), function(el,i) { part_numbers += ( ((i>0)?"|":"") + el.value) });

Open in new window


If you've two form and want to get the value of the fields of the second form :
part_numbers = "";
$.map( $("form:eq(1)").serializeArray(), function(el,i) { part_numbers += ( ((i>0)?"|":"") + el.value) });

Open in new window

0
 
befidledAuthor Commented:
But how do I then submit part_numbers? If I create a hidden inputs, the name gets replaced by the jquery-dynamic-form script.

for instance:

<input type="hidden" name="part_numbers" value="">
<input type="hidden" name="nsns" value="">
<input type="hidden" name="quantity_required" value="">
<input type="hidden" name="condition_required" value="">

gets replaced by:

<input type="hidden" name="parts[parts][1][part_numbers]" value="">
<input type="hidden" name="parts[parts][1][nsns]" value="">
<input type="hidden" name="parts[parts][1][quantity_required]" value="">
<input type="hidden" name="parts[parts][1][condition_required]" value="">
0
Ultimate Tool Kit for Technology Solution Provider

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy now.

 
leakim971PluritechnicianCommented:
>As more parts are added I'd like to be creating a new field that will hold the concatenated value.

If I understand you don't need the name, you need to submit the concatened value

you post it as you want, for example with a redirection :
location.href = "/path/to/ups.php?part_number" + encodeURIComponent(part_numbers);

Open in new window


jQuery.post/get/ajax/&Co :
$.post("/path/to/ups.php", { "part_number":part_number }, function() { alert("success"); });

Open in new window


the form :
$("<input name='part_number' value='" + part_number + "' />").appendTo("body");
$("form").submit();

Open in new window

0
 
befidledAuthor Commented:
I need a solution where I insert hidden inputs into my form. The form is created using Feeform for ExpressionEngine so I need to stay within the parameters of that.

Here's a quick case:

I'm using the form and I've added two additional sets of fields. So I now have fields with the following names:
parts[parts][0][part_numbers]
parts[parts][1][part_numbers]
parts[parts][2][part_numbers]

When I submit the form I need to assign the value of each of these fields to a hidden input with a name of part_number with a "|" separating each value.

So how can I do this when I submit the form?

I have this hidden input:
<input type="hidden" name="part_number" value="">

The value needs to be the concatenated values of parts[parts][0][part_numbers] through parts[parts][2][part_numbers] (or whatever the total count of my additional fields is)

And once I have the js statement to make this occur on submit, where do I put that in my javascript? Should it appear in the header on the  page with the form?
0
 
leakim971PluritechnicianCommented:
>So how can I do this when I submit the form?


part_numbers

Open in new window

$("form").submit(function() {
  part_numbers = "";
  $.map( $("form").serializeArray(), function(el,i) { part_numbers += ( ((i>0)?"|":"") + el.value) });
  $("#part_number").val( part_numbers );
});

Open in new window

0
 
leakim971PluritechnicianCommented:
forget the first code snippet of course...
0
 
leakim971PluritechnicianCommented:
no feedback ?
0
 
leakim971PluritechnicianCommented:
Thanks for the points!
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Upgrade your Question Security!

Your question, your audience. Choose who sees your identity—and your question—with question security.

  • 7
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now