twilitegxa Posted July 30, 2009 Share Posted July 30, 2009 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? Quote Link to comment Share on other sites More sharing options...
twilitegxa Posted July 30, 2009 Author Share Posted July 30, 2009 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. Quote Link to comment 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.