Solved

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

Posted on 2011-03-11
9
508 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
PeopleSoft Has Never Been Easier

PeopleSoft Adoption Made Smooth & Simple!

On-The-Job Training Is made Intuitive & Easy With WalkMe's On-Screen Guidance Tool.  Claim Your Free WalkMe Account Now

 
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

Transaction Monitoring Vs. Real User Monitoring

Synthetic Transaction Monitoring Vs. Real User Monitoring: When To Use Each Approach? In this article, we will discuss two major monitoring approaches: Synthetic Transaction and Real User Monitoring.

Question has a verified solution.

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

I've been trying to accomplish this for a while and it just struck me yesterday how to accomplish this task. I have done searches all over the internet looking for ways to email pages from my applications and finally I have done it!!! Every single s…
Introduction HTML checkboxes provide the perfect way for a web developer to receive client input when the client's options might be none, one or many.  But the PHP code for processing the checkboxes can be confusing at first.  What if a checkbox is…
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…

729 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