Click here to Skip to main content
15,881,881 members
Please Sign up or sign in to vote.
5.00/5 (1 vote)
Here is my sample output on screen:

XML
<form action="/Home/UpdateBooks" id="formBooks" method="post"><div class="isbns" style="margin:25px;">
    <p><input class="text-box single-line" name="[0].isbn" type="text" value="hlkjh" /></p>
    <p><input class="text-box single-line" name="[1].isbn" type="text" value="KhlkjhLK" /></p>
    <p><input class="text-box single-line" name="[2].isbn" type="text" value="jhlkjhL" /></p>
    <p><input class="text-box single-line" name="[3].isbn" type="text" value="saejhjkh" /></p>
    <p><input class="text-box single-line" name="[4].isbn" type="text" value="1234567890" /></p>
    <p><input class="text-box single-line" name="[5].isbn" type="text" value="1234567890" /></p>
</div>


I need to add an input element on a button click -"Add more". How do I get the last index of isbn input array so that i can increment and append to the div?

Thanks for helping in advance. I really appreciate it!
Posted

1 solution

Hi,
Using Jquery....


Try this,

JavaScript
var len = $('.text-box').length;
 
Share this answer
 
Comments
Sunny_Kumar_ 6-Feb-14 7:00am    
thanks mate!

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900