NEWBIE: JS ERROR! HELP!

I

ibsimneej

Someone help me with my code. I copied off a JS from the internet and
tried to modified it in my asp script but it doesn't work. It's
giving me the message: Line:28 Char1 Error: 'document.a294.reporttype'
is null or not an object.

Thanks,
IB

Here is part of my code, any Ideas?:
__________________________________________________________________________

<object RUNAT="Server" ID="Conn" PROGID="ADODB.Connection"></object>
<% RESPONSE.BUFFER=true %>
<HTML>
<HEAD>
<META http-equiv="Content-Language" CONTENT="en-us">
<META http-equiv="Content-Type" CONTENT="text/html;
charset=windows-1252">
<TITLE>This is my test report</TITLE>
</HEAD>
<BODY>
<%
SERVER.SCRIPTTIMEOUT = 480
Conn.CommandTimeout = 480
%>
<!--#include virtual="rep/mgr/connect.asp"-->


<div align="center">
<form action="Thisisatest.asp" method="POST" align="center">
<center>
<table border="0" cellpadding="0" cellspacing="0" width="348">

<form name="a294" >
<tr>
<td width="319" align="right" colspan="3" bgcolor="#000080">
<p align="center"><b><font face="Arial" color="#FFFFFF">Test
Report</font></b></td>
</tr>
<tr>
<td width="355" align="left" style="background-color:#FFFFD7"
colspan="3"><font face="Arial" size="2"><b>Select Report to Run:
</b></font>

<select name="reporttype" size="1" style="background-color:#FFFFD7"
onChange="displaydesc(document.a294.reporttype.selectedIndex)">

<option value="c1">Choice number 1</option>
<option value="c2">Choice number 2</option>
<option value="c3">Choice number 3</option>
<option value="c4">Choice number 4</option>
</selected>

</form>
</td>
</tr>
<tr>
<td colspan="3" width="348" bgcolor="#CCCCCC">
<hr noshade size="2">
</td>

<tr>
<td width="355" align="center" bgcolor="#CCCCCC"
colspan="3"><font face="Arial" size="2"><b>File Status: </b></font>
<select size="1" name="filestatus">
<Option value ="All">All Un/completed </Option>
<Option value ="uncompletee">Uncompleted </Option>
<Option value ="completed">Completed </Option>
</select></td>
</tr>
<tr>
<td width="319" align="right" colspan="3"
bgcolor="#CCCCCC">&nbsp;</td>
</tr>

<span id="descriptions" align="left" style="font: 13px Arial">
</span>


<script>

/***********************************************
* Drop down menu w/ description- © Dynamic Drive
(www.dynamicdrive.com)
* This notice must stay intact for use
* Visit http://www.dynamicdrive.com/ for full source code
***********************************************/

//CUSTOMIZE TEXT DESCRIPTIONS FOR LINKS ABOVE
var textdisplay=new Array()
textdisplay[0]="Choice number 1"
textdisplay[1]="Choice number 2"
textdisplay[2]="Choice number 3"
textdisplay[3]="Choice number 4"

function jumptolink(what){
var selectedopt=document.a294.reporttype.options[what]
if (document.getElementById &&
selectedopt.getAttribute("target")=="newwin")
window.open(selectedopt.value)
else
window.location=selectedopt.value
}

function displaydesc(which){
if (document.all)
descriptions.innerHTML=textdisplay[which]
else if (document.getElementById)
document.getElementById("descriptions").innerHTML=textdisplay[which]
}

displaydesc(document.a294.reporttype.selectedIndex)

document.a294.reporttype.options[0].selected=true

</script>




</table>
</center>
</form>
</div>
</body>

</html>
 
M

Michael Winter

Someone help me with my code. I copied off a JS from the internet and
tried to modified it in my asp script but it doesn't work. It's
giving me the message: Line:28 Char1 Error: 'document.a294.reporttype'
is null or not an object.

<snipped code>

At first, I didn't think you had the named form and form control that the
script is looking for, however I see that you do. Unfortunately, your HTML
is...lacking.
<form action="Thisisatest.asp" method="POST" align="center">
<center>
<table border="0" cellpadding="0" cellspacing="0" width="348">
<form name="a294" >

The biggest problem is that although you can nest forms, you can't place
FORM elements inside a TABLE like you have above. Only table-related
elements can appear directly inside a TABLE element. The simplest solution
is to rename the outer FORM, 'a294', remove the second FORM tag, and
remove the inner-most closing FORM tag.

However, there are better solutions. The best is that you use a different
script; I don't think this one will work properly in any browser other
than IE (that is, it has a terrible design), it has (what I would
interpret as) syntax errors, and it is badly written in general.

I suggest you tidy up your HTML. Aside from the nested form above, there
are some other errors in you page that might stop the script from working.

<SCRIPT>

is invalid HTML. The SCRIPT element requires that the script type is
specified. Instead, use (for JavaScript):

<SCRIPT type="text/javascript">

The OBJECT element below is at the top of your document, outside of the
HTML tag. This is grossly invalid.

<object RUNAT="Server" ID="Conn" PROGID="ADODB.Connection"></object>

All HTML elements must exist within the HTML block. The OBJECT element is
further restricted to the contents of the HEAD block, block-level elements
(P, DIV, Hx headings, etc), and some other inline elements. You must move
that line to one of these locations - the HEAD block is the most obvious.

You should include a DOCTYPE declaration at the beginning of the document.
You should also specify the default scripting language as you use
intrinsic events. The most appropriate for your document, as given, is
shown below (DOCTYPE, then default script language):

Place before the opening HTML tag:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">

Place inside the HEAD block:

<META http-equiv="Content-Script-Type" content="text/javascript">

Finally, don't include server-side script content in posts to this group.
Instead, show the *result* of the server-side script as the browser would
see it. The easiest way to do this is to use 'View source' once you load
the page from the server.

Mike
 
M

Michael Winter

The biggest problem is that although you can nest forms, you can't place
FORM elements inside a TABLE like you have above. Only table-related
elements can appear directly inside a TABLE element. The simplest
solution is to rename the outer FORM, 'a294', remove the second FORM
tag, and remove the inner-most closing FORM tag.

That is partially incorrect; you MUST NOT and CANNOT nest forms. I didn't
read the entity definition for the FORM element correctly. That will have
a big impact on the functionality of your document, but my original advice
should still fix the page.

Mike
 
I

ibsimneej

Thanks for the suggestion as I've made many changes. As a newbie, I
can always use more tips as I dwell into this Javascript/ASP/HTML
stuff. I found a different script and got it to work the way I wanted
to.

Thanks again,

IB.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,774
Messages
2,569,598
Members
45,149
Latest member
Vinay Kumar Nevatia0
Top