nottoolate Posted December 16, 2011 Share Posted December 16, 2011 Hello, I am creating a form and I have a field set for client information and the ability to add another field set for another client if needed. As of now the additional field sets' field id adds by 1 which is good, but I would like for each of the fields in the field set to add by 1 as well. Here is the code: var _counter = 0; function Add() { _counter++; var oClone = document.getElementById("client").cloneNode(true); oClone.id += (_counter + ""); document.getElementById("placehere").appendChild(oClone); Quote Link to comment https://forums.phpfreaks.com/topic/253311-clone-field-set/ Share on other sites More sharing options...
nottoolate Posted December 30, 2011 Author Share Posted December 30, 2011 any input? Here is what I'm getting: The original section <fieldset id="child1"> <table id="1"> <tr> <td>Child</td> <td><select name="pm1" id="pm1"><option value="1">Yes</option><option value="2">No</option></td> </tr> <td>Account</td> <td><input type="text" id="pa1" name="pa1" /></td> </tr> </table> </fieldset> The newly added section (Notice how the id is the same except for the fieldset) <fieldset id="child2"> <table id="1"> <tr> <td>Child</td> <td><select name="pm1" id="pm1"><option value="1">Yes</option><option value="2">No</option></td> <td>Account</td> <td><input type="text" id="pa1" name="pa1" /></td> </tr> </table> </fieldset> What I want <fieldset id="child2"> <table id="1"> <tr> <td>Child</td> <td><select name="pm2" id="pm2"><option value="1">Yes</option><option value="2">No</option></td> <td>Account</td> <td><input type="text" id="pa2" name="pa2" /></td> </tr> </table> </fieldset> Quote Link to comment https://forums.phpfreaks.com/topic/253311-clone-field-set/#findComment-1302656 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.