Javascript Text Insertion Not Working in Chrome?
-
07-07-2019 - |
Question
Hey guys, this bit of code works in IE but not in Chrome, any idea why?
<script type="text/javascript">
function fillreply(commentID){
var item = document.getElementById("replyto");
item.value=commentID;
}
</script>
...
...
<div id="makereply" class="hidden">Reply to: <input type="text" size="6"
name="replyto" readonly />
In IE javascript:fillreply(4);
will work but not in chrome where nothing happens.
Solution
Your input doesn't have an id attribute, and you're trying to retrieve it with getElementById.
<input type="text" size="6" id="replyto" name="replyto" readonly="readonly" />
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow