What is the difference between these codes?
- by dhaliwaljee
<input type='text' id='txt' name='txtName' size='20' value='testing'/>
<script type="text/javascript" language='javascript'>
var val = document.getElementsByName('txtName');
alert(val[0].value);
alert(window.txtName.value);
</script>
In above code we are using
alert(val[0].value);
alert(window.txtName.value);
these two ways for getting value from object. What is the difference between both ways and which way is best.