Jump to content

Recommended Posts

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);

 

Link to comment
https://forums.phpfreaks.com/topic/253311-clone-field-set/
Share on other sites

  • 2 weeks later...

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>

 

Link to comment
https://forums.phpfreaks.com/topic/253311-clone-field-set/#findComment-1302656
Share on other sites

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.