.NET and JavaScript Forms
Is there a new way to reference forms and elements in javascript when using .net?
My code that works in html, but when I try in .NET, I get an error that says: 'document.forms[...].elements' is null or not an object
Anyone know why this is happening?
Here's my html code:
<html>
<head>
<SCRIPT LANGUAGE="JavaScript">
<!-- Begin
function formHandler(){
var selectValues = new Array();
for ( var j = 1; j <= 10; ++j ){
var sel = document.forms["B"+j].elements["C"+j];
selectValues[j] = sel.options[sel.selectedIndex].value;
if(selectValues[j] != ""){
window.open(selectValues[j], "_self");
}
}
}
// End -->
</SCRIPT>
</head>
<body>
<SCRIPT LANGUAGE="JavaScript">
<!-- Begin
for ( var j = 1; j <= 10; ++j ){
document.writeln('<form method="POST" action="#" name="B' + j + '"style="margin-bottom:2; margin-top:2;">')
document.writeln('<select name="C' + j +'" size=1 onChange="javascript:formHandler()">')
document.writeln('<option selected value="">-- Select a Link --</option>')
document.writeln('<option value="#?page=1&id=' + j + '">Page 1</option>')
document.writeln('<option value="#?page=2&id=' + j + '">Page 2</option>')
document.writeln('<option value="#?page=3&id=' + j + '">Page 3</option>')
document.writeln('</select>')
document.writeln('</form>')
}
// End -->
</SCRIPT>
</body>
</html>
|