Solved

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

Posted on 2011-03-11
9
502 Views
Last Modified: 2012-05-11
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
Comment
Question by:befidled
  • 7
  • 2
9 Comments
 
LVL 82

Expert Comment

by:leakim971
ID: 35113315
0
 
LVL 82

Expert Comment

by:leakim971
ID: 35113316
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
 
LVL 1

Author Comment

by:befidled
ID: 35113476
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
Networking for the Cloud Era

Join Microsoft and Riverbed for a discussion and demonstration of enhancements to SteelConnect:
-One-click orchestration and cloud connectivity in Azure environments
-Tight integration of SD-WAN and WAN optimization capabilities
-Scalability and resiliency equal to a data center

 
LVL 82

Expert Comment

by:leakim971
ID: 35113524
>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
 
LVL 1

Author Comment

by:befidled
ID: 35118200
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
 
LVL 82

Accepted Solution

by:
leakim971 earned 500 total points
ID: 35124960
>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
 
LVL 82

Expert Comment

by:leakim971
ID: 35124967
forget the first code snippet of course...
0
 
LVL 82

Expert Comment

by:leakim971
ID: 35139389
no feedback ?
0
 
LVL 82

Expert Comment

by:leakim971
ID: 35443057
Thanks for the points!
0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
how can i get 4 nd 5 ? 3 31
Access RV042 GUI / Browser Issues 25 48
Google Analytics setup 5 50
How to make google charts responsive 4 4
In my daily work (mainly using ASP.net), I need to write a lot of JavaScript code. One of the most repetitive tasks I do are the jQuery Ajax calls. You know: (CODE) I don't know if for you it's the same, but for me is soooo tedious to write the …
This article demonstrates how to create a simple responsive confirmation dialog with Ok and Cancel buttons using HTML, CSS, jQuery and Promises
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

860 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question