Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
0

JScript error : Object expected.

New Here ,
Apr 02, 2007 Apr 02, 2007

Copy link to clipboard

Copied

Hi,

Can someone please help me out here.
I am using asp javascript to develop my web page, i have the following function
defined in the head section of the page:

<head>
<script type="text/javascript">
function DisableSubGroup()
{
document.getElementById("SubGroupDD").disabled = "disabled";
}
</script>
</head>

I call the function from within my code in the following way.

<form action="CategoryListing.Mod.asp" method="post" name="SubForm" target="_self" id="SubForm">
<p>
<% if(ParentValue == String("Y"))
{
DisableSubGroup(); //Function call
}
%>
<select name="SubGroupDD" class="DefaultShortBox" id="SubGroupList" onchange="SubForm.submit()"
option selected= "<%Session("ActiveCategory")%>">

When i run it i get the following error every time..

Error Type:
Microsoft JScript runtime (0x800A138F)
Object expected
/DCASuppliersDatabase/CategoryListing.Mod.asp, line 218

What does it mean?
How do i get rid of it?
Regards

fifo
TOPICS
Server side applications

Views

910
Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Apr 02, 2007 Apr 02, 2007

Copy link to clipboard

Copied

You cannot call client side functions on the server.

--
Jules
http://www.charon.co.uk/charoncart
Charon Cart 3
Shopping Cart Extension for Dreamweaver MX/MX 2004





Votes

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Apr 02, 2007 Apr 02, 2007

Copy link to clipboard

Copied

fifo85 wrote:

> Hi,
>
> Can someone please help me out here.
> I am using asp javascript to develop my web page, i have the following function
> defined in the head section of the page:
>
> <head>
> <script type="text/javascript">
> function DisableSubGroup()
> {
> document.getElementById("SubGroupDD").disabled = "disabled";
> }

Normally the disabled property is Boolean
document.getElementById("SubGroupDD").disabled = true;

> </script>
> </head>
>
> I call the function from within my code in the following way.
>
> <form action="CategoryListing.Mod.asp" method="post" name="SubForm"
> target="_self" id="SubForm">
> <p>
> <% if(ParentValue == String("Y"))
> {
> DisableSubGroup(); //Function call
> }
> %>

I'm not a vb/asp person, but I imagine that you can only make the call
to the DisableSubGroup() function *after* the element is writtten to the
document.



> <select name="SubGroupDD" class="DefaultShortBox" id="SubGroupList"
> onchange="SubForm.submit()"
> option selected= "<%Session("ActiveCategory")%>">

You are missing the closing ">" from the select tag, and the opening "<"
from the option tag.
And "SubForm.submit()" should be:
"this.form.submit()"
or
"document.SubForm.submit()"

Mick


>
> When i run it i get the following error every time..
>
> Error Type:
> Microsoft JScript runtime (0x800A138F)
> Object expected
> /DCASuppliersDatabase/CategoryListing.Mod.asp, line 218
>
> What does it mean?
> How do i get rid of it?
> Regards
>
> fifo
>
>

Votes

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Apr 02, 2007 Apr 02, 2007

Copy link to clipboard

Copied

Julian Roberts wrote:

> You cannot call client side functions on the server.
>
<script>
<?php echo "x=".$_GET["var"] ?>
function foo(){
if(x && x=="bar"){
alert(x)
}
}
foo()
</script>
Mick

Votes

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Apr 02, 2007 Apr 02, 2007

Copy link to clipboard

Copied

Yes, that's the way to do it. Execute the client-side code on the client.

--
Jules
http://www.charon.co.uk/charoncart
Charon Cart 3
Shopping Cart Extension for Dreamweaver MX/MX 2004





Votes

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Apr 03, 2007 Apr 03, 2007

Copy link to clipboard

Copied

Hi,

I have just tried the following code putting the script header to execute it on the client side:
<script>
if(ParentValue == String("Y"))
{
EnableSubGroup();
}
else
{
DisableSubGroup();
}
</script>

I do not get the object expected error anymore
but the functions don't work, why is this?

----Function definition ------
<script type="text/javascript">
function EnableSubGroup()
{
document.forms["SubForm"].elements["SubGroupDD"].disabled='false';
}
function DisableSubGroup()
{
document.forms["SubForm"].elements["SubGroupDD"].disabled='true';
}
</script>

Votes

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Apr 03, 2007 Apr 03, 2007

Copy link to clipboard

Copied

fifo85 wrote:

> Hi,
>
> I have just tried the following code putting the script header to execute it
> on the client side:
> <script>
> if(ParentValue == String("Y"))
> {
> EnableSubGroup();
> }
> else
> {
> DisableSubGroup();
> }
> </script>

Where do you get "ParentValue" from?
String("Y") is redundant.
if(ParentValue == "Y")


>
> I do not get the object expected error anymore
> but the functions don't work, why is this?
>
> ----Function definition ------
> <script type="text/javascript">
> function EnableSubGroup()
> {
> document.forms["SubForm"].elements["SubGroupDD"].disabled='false';
> }

document.forms["SubForm"].elements["SubGroupDD"].disabled=false;

There shoud be no quotes surrounding "false".

> function DisableSubGroup()
> {
> document.forms["SubForm"].elements["SubGroupDD"].disabled='true';
> }
document.forms["SubForm"].elements["SubGroupDD"].disabled=true;

> </script>


I think you're taking the wrong approach, if you are trying to disable a
form control depending on a server variable.

Mick

Votes

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Apr 04, 2007 Apr 04, 2007

Copy link to clipboard

Copied

Thanks for the response mick,

Parent value gets its value from the record set in the following code
var ParentValue = (rsGroups.Fields.Item("IsParent").Value);
in the server side code

then i use the code below to check its value
<script>
> if(ParentValue == String("Y"))
> {
> EnableSubGroup();
> }
> else
> {
> DisableSubGroup();
> }
> </script>

Whats wro ng with this?
Can't i do this?
What do you mean by server variable?
i didn't know that server and client variables have to be separate. Is this true?

thanks again

fifo

Votes

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Apr 04, 2007 Apr 04, 2007

Copy link to clipboard

Copied

fifo85 wrote:

> Thanks for the response mick,
>
> Parent value gets its value from the record set in the following code
> var ParentValue = ();
> in the server side code
>
> then i use the code below to check its value
> <script>
> > if(ParentValue == String("Y"))
> > {
> > EnableSubGroup();
> > }
> > else
> > {
> > DisableSubGroup();
> > }
> > </script>
>
> Whats wro ng with this?
> Can't i do this?
> What do you mean by server variable?
> i didn't know that server and client variables have to be separate. Is this
> true?

Yes this is true. But you can use the server language to print the
javascript variable.

Pseudo server code:
<servertag>
print "<script> var ParentValue='"
print rsGroups.Fields.Item("IsParent").Value;
print "'</script>";
</servertag>

But show me what you have done so far.


Mick

>
> thanks again
>
> fifo
>
>
>

Votes

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Apr 05, 2007 Apr 05, 2007

Copy link to clipboard

Copied

I have tried putting the following code along with my server side code This time placing the script tag round the
function call This works sometimes and
sometimes it doesn't - strange!
<%
if(ParentValue != String("Y"))
{%>
<script>
DisableSubGroup();
</script>
<%}%>

<script type="text/javascript">
function DisableSubGroup()
{
document.forms["SubForm"].elements["SubGroupDD"].disabled=true;
document.forms["SubGroupTFForm"].elements["SubGroupTF"].value =String("G");
document.getElementById("SubGroupDD").className = "GreyedShortBox";
}
</script>

Votes

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Apr 05, 2007 Apr 05, 2007

Copy link to clipboard

Copied

LATEST
I need to see the whole page(source), fifo.
Mick


fifo85 wrote:

> I have tried putting the following code along with my server side code This
> time placing the script tag round the
> function call This works sometimes and
> sometimes it doesn't - strange!
> <%
> if(ParentValue != String("Y"))
> {%>
> <script>
> DisableSubGroup();
> </script>
> <%}%>
>
> <script type="text/javascript">
> function DisableSubGroup()
> {
> document.forms["SubForm"].elements["SubGroupDD"].disabled=true;
> document.forms["SubGroupTFForm"].elements["SubGroupTF"].value =String("G");
> document.getElementById("SubGroupDD").className = "GreyedShortBox";
> }
> </script>
>
>

Votes

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines