Jump to content

Jquery Selector Logic, Copying Form Inputs, Incrementing Name Values


Arnsenal

Recommended Posts

Hello All

 

I have a problem with my following example on js fiddle.

 

http://jsfiddle.net/7nx6j/2/

 

My goal is to append on additional group of input fields into a existing form when a button is clicked.

 

The server side php needs the name attributes of the input fields to be unique.

 

So with j query I copy and append a div containing the addition input elements into a containing div when a button is clicked.

 

Also, I change the value of the name attributes by incrementing a var and appending that number value to the existing value of all the name attribute.

 

It works except for when I go to add the 2nd set of input elements. The Jscript selector selects all the existing name attributes with the ascendant class .appendRunTableRight and appends the increment value. So the first set of input elements will have a name attribute looking like :  name="mill_rpm1_2_3"            the second set will look like:    name="mill_rpm2_3"    and the third:  name="mill_rpm_3"    and so on...

 

So logically the jquery selector must only select the last div with class .appendRunTableRight not all of them.

 

Given my current script Im not sure how to rewrite it to fix the problem.

 

Here is to hoping that someone will understand my problem and what Im trying to do!

 

Thank You

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.