I've got the following code to get the value of input name array key with javascript:
var input = document.querySelector('input');
var value = input.name.match(/\[(.*?)\]/)[1];
console.log(value);
<input type="text" name="hello[101][]" />
Now this works fine.
But I am wondering if there is a better way then ...name.match(/\[(.*?)\]/)[1]; to get the input name array key value(s)? Like is there a way to convert the hello[101][] string to a kind of javascript array or object? Like what if I want to get all keys from:
<input type="text" name="hello['one'][101]['test'][]" />
eval()to process that string as codeeval()? doesn't shows anything jsfiddle.net/yv4ceffrinput.nameis a string though