html - How to access form input value in javascript with special characters in input name? -


i have form cannot change input value field names. 1 such field in html follows:

<body> <form id="f" method="get" action="/code/submit.php"> <input type="text" name="var[list]" id="ixv[list]" value=""> <button type="button" title="save" onclick="check();"> </form> </body> 

now in javascript, want access input value. tried this, , of course doesn't work since [] looks array in js.

function check() { var x=var[list].value; alert(x); } 

the problem variable name has [] in it. how can input field value in javascript?

this works:

http://jsfiddle.net/mqv82/1/

<input type="text" name="var[list]" id="ixv[list]" value="foo">  alert(document.getelementbyid('ixv[list]').value); 

Comments

Popular posts from this blog

Winapi c++: DialogBox hangs when breaking a loop -

vb.net - Font adding using PDFsharp -

javascript - jQuery iScroll clickable list elements while retaining scroll? -