Jump to content

Limiting Clone Based On Select Option Value Total


twilitegxa

Recommended Posts

I have the following table that is cloning, and I want to limit the number of clones a user can add by adding the total of the second select options values (which are numbered 1-6). I want to limit the total to be no more than 10. Here is the page:

 

<script type="text/javascript">

function addRowClone(tblId)
{
  var tblBody = document.getElementById(tblId).tBodies[0];
  var newNode = tblBody.rows[0].cloneNode(true);
  tblBody.appendChild(newNode);
}
</script>

<form>
<table id="tblClone">
<thead>
<tr>
<th>Sub-Attribute</th>
<th>Level</th>
</tr>
</thead>
<tbody>
<tr>
<td>
<select name="attribute" size="1">
<option value="Animal Guardian">Animal Guardian</option>
<option value="Elemental Control">Elemental Control</option>
<option value="Item Of Power">Item Of Power</option>
<option value="Rejuvenation">Rejuvenation</option>
<option value="Combined Attacks">Combined Attacks</option>
<option value="Emotional Control">Emotional Control</option>
<option value="Knight Attack">Knight Attack</option>
<option value="Sailor Scout Attack">Sailor Scout Attack</option>
</select></td>
<td>
<select>
<option value="1">1</option>
<option value="2">2</option>
<option value="3">3</option>
<option value="4">4</option>
<option value="5">5</option>
<option value="6">6</option>
</select></td>
</tr>
</tbody>
</table><br />
<input type="button" class="add" value="Add Sub-Attribute" onclick="addRowClone('tblClone');" />
</form>

 

For example, the user cannot add another "attribute" (done by clicking the button which clones the row), if they have already chosen 4 attributes with levels of 2, 2, 3, 3. Is there a way to limit how many clone they can add based on the total of the second select field of the table?

Link to comment
Share on other sites

Sorry, there is a mistake. I need the total to be based on a different value. I added another table with fields:

 

<table>
<thead>
<tr>
<th>Attribute</th>
<th>Level</th>
</tr>
</thead>
<tbody>
<tr>
<td>
<input type="text" value="Scout/Knight Attribute" size="19" name="attribute" />
</td>
<td>
<select name="attribute_level">
<option value="1">1</option>
<option value="2">2</option>
<option value="3">3</option>
<option value="4">4</option>
<option value="5">5</option>
<option value="6">6</option>
</select>
</td>
</tr>
</tbody>
</table>

 

In this table, the value of the level field will be multiplied by 10. This value is the value that needs to be used to determine the limit on the clones.

Link to comment
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.