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:
<input type="text" name="var[list]" id="ixv[list]" value="foo"> alert(document.getelementbyid('ixv[list]').value);
Comments
Post a Comment