Jump to content

Jquery Selector Logic, Copying Form Inputs, Incrementing Name Values


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

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.