Being new to asp.net and javascript, I am struggling to find helpful web resources and troubleshoot javascript errors. The specific issue I'm facing is with the line
oFormObject.submit();
which throws a Microsoft JScript runtime error: Object doesn't support this property or method.
To improve the aesthetics of my webpage, I decided to use links that function as buttons instead of creating multiple buttons in a table. However, I've read that this approach may lead to browser rendering issues and unnecessary traffic. Additionally, the CSS I found to style buttons like links is causing alignment and spacing problems.
<!DOCTYPE HTML PUBLIC
"-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head><link rel="stylesheet" type="text/css" href="DefectSeverity.css" /><title>
Defect Severity Assessment Code List
</title></head>
<body>
<form name="form1" method="post" action="CodeList.aspx" id="form1">
<div>
<input type="hidden" name="__VIEWSTATE" id="__VIEWSTATE" value="/wEPDwUJNjQzMTI3NjU4ZGSW2wNBW3eGztyO+Tftc5BB8A6cMg==" />
</div>
<div>
<p>Welcome Maslow</p><SCRIPT language="JavaScript">
function submitForm(intId)
{ oFormObject= document.getElementById(""form"+_StrCodeId + @""");
oFormElement= document.getElementById("codeId");
oFormElement.value=intId;
oFormObject.submit();
}
</SCRIPT> <form method="post" action="CodeAssessment.aspx" id="formcodeId">
<table name="codeId" id="codeId" value="0" type="hidden" class="linkTable">
<tr>
<th>Completed</th><th>Code</th><th>Description</th><th>Code Present Since</th>
</tr><tr class="row">
<td><input name="401" type="checkbox" value="401" DISABLED /></td><td><a href="javascript:submitForm(0);">401</a></td><td>Missing Original Document/form</td><td>2009.10.16</td>
</tr><tr class="rowAlternate">
<td><input name="NDMI" type="checkbox" checked="checked" value="NDMI" DISABLED /></td>
<td><a href="javascript:submitForm(1);">NDMI</a></td>
<td>Note date is missing</td> <td>2009.10.15</td>
</tr>
</table><input type="submit" />
</form>
</div>
</form>
</body>
</html>
By changing the script line to oFormObject= document.forms[0];
, the form submits the asp.net's viewstate form returning to the same page rather than the intended destination. This suggests that the rest of the code on the page is functioning properly.