I have the following input field, and I'm trying to figure out how to increment the value of a specific bracketed value...
How would I go about incrementing a particular bracketed value (i.e., title[0][subtitle][3] becomes title[0][subtitle][4])?
I've managed to partially get it working by hardcoding a value... The code below essentially does what I want, except that I can't figure out how to store and increment that particular value dynamically...
(also posted on jsfiddle: http://jsfiddle.net/492bD/ )...
<input type="text" class="form-text" value="" name="title[0][subtitle][0]">
<button id="clickme">Click me</button>
$('#clickme').live('click', function() {
var lastSubTitle = $('input.form-text').attr('name');
var newSubTitle = lastSubTitle.replace(/^(.*\[[0-9]+\].*)(\[[0-9]+\])(.*)$/, '$1[20]$3');
alert(newSubTitle);
});