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

Perl - how to grep a block of text from a file -

delphi - How to remove all the grips on a coolbar if I have several coolbands? -

javascript - Animating array of divs; only the final element is modified -