Arnsenal Posted July 25, 2012 Share Posted July 25, 2012 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 Quote Link to comment https://forums.phpfreaks.com/topic/266229-jquery-selector-logic-copying-form-inputs-incrementing-name-values/ Share on other sites More sharing options...
Arnsenal Posted July 26, 2012 Author Share Posted July 26, 2012 Very long explanation, Very easy fix. All I had to do was add :last to my Jquery selectors. Jquery so good. Quote Link to comment https://forums.phpfreaks.com/topic/266229-jquery-selector-logic-copying-form-inputs-incrementing-name-values/#findComment-1364584 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.