Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

object expected error when calling javascript function

Status
Not open for further replies.

rmr15

Programmer
Jul 23, 2001
1
US


I am having problems executing a function from within
an active server page. I get an "object expected" error
when I select one of the values in the drop down list.
I have simplified the two asp files and they are listed
below.


main.asp
******************************************************
<%@ Language=JavaScript %>
<HTML>
<HEAD>
<TITLE>ROADMAP</TITLE>
</HEAD>
<%
Response.Write('<FRAMESET COLS=&quot;17%, 83%&quot; FRAMEBORDER=&quot;0&quot; FRAMESPACING=&quot;0&quot; BORDER=&quot;0&quot;>');
Response.Write('<FRAME NAME=&quot;disChoices&quot; SRC=&quot;displayChoices.asp&quot;>');
Response.Write('</FRAMESET>');
%>
</HTML>



displayChoices.asp
*******************************************************
<%@ Language=JavaScript %>
<HTML>
<HEAD>

<TITLE>STANDARDS ROADMAP</TITLE>
<%

function alldone() {
alert(&quot;All done&quot;);
}

function displayChoices()
{
Response.Write('<BR><BR>');
Response.Write('<CENTER>');
Response.Write('<p>');
Response.Write('<BR><BR>');
Response.Write('<I><B><FONT COLOR=#FFFFFF>Available Reports</FONT></B><I>');
Response.Write('<FORM NAME=reports METHOD=POST TARGET=disSelections>');
Response.Write('<SELECT NAME=selectReport onChange=&quot;allDone()&quot;>');
Response.Write('<OPTION VALUE=&quot;1&quot;>ONE</OPTION>');
Response.Write('<OPTION VALUE=&quot;2&quot;>TWO</OPTION>');
Response.Write('<OPTION VALUE=&quot;3&quot;>THREE</OPTION>');
Response.Write('<OPTION VALUE=&quot;4&quot;>FOUR</OPTION>');
Response.Write('<OPTION VALUE=&quot;5&quot;>FIVE</OPTION>');
Response.Write('</SELECT>');
Response.Write('<p>');
Response.Write('</FORM>');
Response.Write('</CENTER>');
}
%>
</HEAD>
<BODY BGCOLOR=#003399>
<%
Response.Write(displayChoices());
%>
</BODY>
</HTML>
 
Hi rmr15,

The problem is that the onchange event happens on Client side, so your function alldone (btw, it should be allDone) which is only visible at server doesn't exist anymore.

So, what you should do is make it available at Client side, like this:

<script language=&quot;JavaScript&quot;>
function allDone() {
alert(&quot;All done&quot;);
}
</script>

Hope to be of service?

Gtz,

Kristof
 
Javascript is case-sensitive: allDone() in your onchange and alldone() is the function name.

BTW: This is HTML with Javascript, so mixing it with ASP is not good.



TEST.HTM

<HTML>

<script language=Javascript>

function alldone() {
alert('All done');
}
</script>

<BODY>
<CENTER>
<B>Available Reports</B>
<FORM NAME=reports>
<SELECT NAME=selectReport onChange=&quot;allDone()&quot;>
<OPTION VALUE=&quot;1&quot;>ONE
<OPTION VALUE=&quot;2&quot;>TWO
<OPTION VALUE=&quot;3&quot;>THREE
<OPTION VALUE=&quot;4&quot;>FOUR
<OPTION VALUE=&quot;5&quot;>FIVE
</SELECT>
</FORM>
</CENTER>
</BODY>
</HTML>

br
Gerard
 
now i made the same error!!*&!(*&^!*^%!&^!%!
br
Gerard
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top