Hii brainchild!!
hope this will help you
**********ErrorCode.html**************
<script>
var myString = document.form1.textfield.value;
alert(myString)
</script>
<form name=form1>
<input type=text name=textfield>
</form>
Reason-since contents are rendered from top to bottom ,at the line var myString = document.form1.textfield.value;
script is looking for form1 and textfield which are not rendered at the time.it gives the error
**********Solution1.html**************
<script>
function callme()
{
var myString = document.form1.textfield.value;
alert(myString)
}
</script>
<form name=form1>
<input type=text name=textfield>
<input type=button name=btnName value="call" onclick="callme()">
</form>
**********Solution2.html**************
<form name=form1>
<input type=text name=textfield>
</form>
<script>
var myString = document.form1.textfield.value;
alert(myString)
</script>
Reason-No problem , since form and text field already rendered ,no problem to call at the end
Cheers :)
vinod
|