user94 user94 - 1 year ago 65
HTML Question

how to access contents of a text box using name of the input text box element in javascript?

function display() {
var x = document.nid.value;

<meta charset="ISO-8859-1">
<title>Print Reverse of a number</title>

Enter number
<input type="number" size="20" name="nid">
<td align="center" colspan="2">
<input type="submit" value="submit" onclick="display()">

Answer Source

Your should replace

var x = document.nid.value


x = document.getElementsByName("nid")[0].value;
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download