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 Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Expected semi-colon error and Object expected error 2

Status
Not open for further replies.

Light777

Programmer
May 15, 2003
32
0
0
US
I am doing a site for a computer store and I have come across a couple of errors that I can't figure out, if someone could help me that would be greatly appreciated.

Here is the code: (At the end of this post, I'll describe the errors that I am getting)

<%@Language = VBScript%>

<html>

<head>
<title>Shoreline Computer Systems</title>
<link rel=stylesheet href=&quot;Shoreline.css&quot; type=&quot;text/css&quot;>
<script type=&quot;text/javascript&quot;>
function MakeMain() //Switch to Main Content
{
If (document.getElementById(&quot;MainContent&quot;).style.visibility == &quot;hidden&quot;)
{
document.getElementById(&quot;SideContent&quot;).style.visibility = &quot;hidden&quot;;
document.getElementById(&quot;SideContentTop&quot;).style.visibility = &quot;hidden&quot;;
document.getElementById(&quot;SideContentMiddle&quot;).style.visibility = &quot;hidden&quot;;
document.getElementById(&quot;SideContentBottom&quot;).style.visibility = &quot;hidden&quot;;
document.getElementById(&quot;SideContentTopText&quot;).style.visibility = &quot;hidden&quot;;
document.getElementById(&quot;MainContent&quot;).style.visibility = &quot;visible&quot;;
}
}

function MakeSide(Content) //Switch to Side Content
{
If (document.getElementById(&quot;MainContent&quot;).style.visibility == &quot;visible&quot;)
{
document.getElementById(&quot;SideContent&quot;).style.visibility = &quot;visible&quot;;
document.getElementById(&quot;SideContentTop&quot;).style.visibility = &quot;visible&quot;;
document.getElementById(&quot;SideContentMiddle&quot;).style.visibility = &quot;visible&quot;;
document.getElementById(&quot;SideContentBottom&quot;).style.visibility = &quot;visible&quot;;
document.getElementById(&quot;SideContentTopText&quot;).style.visibility = &quot;visible&quot;;
document.getElementById(&quot;MainContent&quot;).style.visibility = &quot;hidden&quot;;
}
switch(Content)
{
case(Content==&quot;Tablet&quot;):
document.Computer.src = &quot;Images/Tablet-pc.gif&quot;;
document.getElementById(&quot;SideContentTopText&quot;).innerHTML = &quot;<div align=&quot;right&quot;><font face=&quot;Courier&quot; size=4>Tablet PC | Specifications</font></div>&quot;;
document.getElementById(&quot;SideContentBottom&quot;).innerHTML = &quot;<div align=&quot;right&quot;><font face=&quot;Courier&quot; size=5><b>Starting at $2050</b></font></div>&quot;;
break
case(Content==&quot;Workstation&quot;):
document.Computer.src = &quot;Images/Workstation.gif&quot;;
document.getElementById(&quot;SideContentTopText&quot;).innerHTML = &quot;<div align=&quot;right&quot;><font face=&quot;Courier&quot; size=4>Workstation | Specifications</font></div>&quot;;
document.getElementById(&quot;SideContentBottom&quot;).innerHTML = &quot;<div align=&quot;right&quot;><font face=&quot;Courier&quot; size=5><b>Starting at $800</b></font></div>&quot;;
break
case(Content==&quot;Notebook&quot;):
document.Computer.src = &quot;Images/Notebook.gif&quot;;
document.getElementById(&quot;SideContentTopText&quot;).innerHTML = &quot;<div align=&quot;right&quot;><font face=&quot;Courier&quot; size=4>Notebook | Specifications</font></div>&quot;;
document.getElementById(&quot;SideContentBottom&quot;).innerHTML = &quot;<div align=&quot;right&quot;><font face=&quot;Courier&quot; size=5><b>Starting at $1150</b></font></div>&quot;;
break
}
}
</script>
</head>

<body bgcolor=&quot;#ffffff&quot;>
<%
Sub RandomMessage()
Dim objx, objy, message, lines
Set objx=Server.CreateObject(&quot;Scripting.FileSystemObject&quot;)
Set objy=objx.OpenTextFile(&quot;Sayings.txt&quot;, 2)

lines = 0
Do While Not objy.AtEndOfStream
message = objy.ReadLine
lines = lines + 1
loop

randomize
lines = Int(Rnd * lines) + 1

For i = 1 to lines
message = objy.ReadLine
Next

Response.Write(&quot;<b><font size='4'>&quot; + message + &quot;</font></b>&quot;)
End Sub
%>

<!--Set-up the background-->
<div id=&quot;Background&quot;></div>
<div id=&quot;TopBackground&quot; class=&quot;TransDown&quot;>
<img src=&quot;Images/TopBackground.gif&quot; alt=&quot;&quot; height=&quot;100%&quot; width=&quot;100%&quot; border=&quot;0&quot;></div>
<div id=&quot;TopMenuBar&quot;>
<img src=&quot;Images/top-bar.gif&quot; alt=&quot;&quot; height=&quot;100%&quot; width=&quot;100%&quot; border=&quot;0&quot;>
<div id=&quot;TopTextNav&quot;>
<a href=&quot;Networking.html&quot; target=&quot;ContentFrame&quot; onClick=&quot;MakeMain();&quot;>Networking</a> | <a href=&quot; Login</a> | <a href=&quot;Support.html&quot; target=&quot;ContentFrame&quot; onClick=&quot;MakeMain();&quot;>Support</a> | <a href=&quot; Design</a> | <a href=&quot;AboutUs.html&quot; target=&quot;ContentFrame&quot; onClick=&quot;MakeMain();&quot;>About Us</a></div>
</div>

<!--Set-up the Left Menu-->
<div id=&quot;LeftMenuBar&quot; class=&quot;BoxTrans&quot;>
<img src=&quot;Images/left-box.gif&quot; alt=&quot;&quot; height=&quot;100%&quot; width=&quot;100%&quot; border=&quot;0&quot;>
<div id=&quot;Home&quot; style=&quot;position: absolute; top: 1px; left: 1px; width: 100%; height: 18%; visibility: visible&quot;>
<div align=&quot;center&quot;>
<img src=&quot;Images/Tower.gif&quot; alt=&quot;&quot; height=&quot;100%&quot; width=&quot;75%&quot; border=&quot;0&quot;>
</div>
</div>
<div id=&quot;HomeText&quot; style=&quot;position: absolute; top: 18%; left: 1px; width: 100%; height: 7%; visibility: visible&quot;>
<div align=&quot;center&quot;>
<a href=&quot;Home.html&quot; target=&quot;ContentFrame&quot; onClick=&quot;MakeMain();&quot;>Home</a>
</div>
</div>
<div id=&quot;Tablet&quot; style=&quot;position: absolute; top: 25%; left: 1px; width: 100%; height: 18%; visibility: visible&quot;>
<div align=&quot;center&quot;>
<img src=&quot;Images/Tablet-PC.gif&quot; alt=&quot;&quot; height=&quot;100%&quot; width=&quot;75%&quot; border=&quot;0&quot;>
</div>
</div>
<div id=&quot;TabletText&quot; style=&quot;position: absolute; top: 43%; left: 1px; width: 100%; height: 7%; visibility: visible&quot;>
<div align=&quot;center&quot;>
<a href=&quot;Tablet.html&quot; target=&quot;SideContentFrame&quot; onClick=&quot;MakeSide('Tablet');&quot;>Tablet PC</a>
</div>
</div>
<div id=&quot;Workstation&quot; style=&quot;position: absolute; top: 50%; left: 1px; width: 100%; height: 18%; visibility: visible&quot;>
<div align=&quot;center&quot;>
<img src=&quot;Images/Workstation.gif&quot; alt=&quot;&quot; height=&quot;100%&quot; width=&quot;75%&quot; border=&quot;0&quot;>
</div>
</div>
<div id=&quot;WorkstationText&quot; style=&quot;position: absolute; top: 68%; left: 1px; width: 100%; height: 7%; visibility: visible&quot;>
<div align=&quot;center&quot;>
<a href=&quot;Workstation.html&quot; target=&quot;SideContentFrame&quot; onClick=&quot;MakeSide('Workstation');&quot;>Workstation</a>
</div>
</div>
<div id=&quot;Notebook&quot; style=&quot;position: absolute; top: 75%; left: 1px; width: 100%; height: 18%; visibility: visible&quot;>
<div align=&quot;center&quot;>
<img src=&quot;Images/Notebook.gif&quot; alt=&quot;&quot; height=&quot;100%&quot; width=&quot;75%&quot; border=&quot;0&quot;>
</div>
</div>
<div id=&quot;NotebookText&quot; style=&quot;position: absolute; top: 93%; left: 1px; width: 100%; height: 7%; visibility: visible&quot;>
<div align=&quot;center&quot;>
<a href=&quot;Notebook.html&quot; target=&quot;SideContentFrame&quot; onClick=&quot;MakeSide('Notebook');&quot;>Notebook</a>
</div>
</div>
</div>

<!--Set-up the scrolling sayings box-->
<div id=&quot;TopDialogBar&quot;>
<img src=&quot;Images/dialog-bar.gif&quot; alt=&quot;&quot; height=&quot;100%&quot; width=&quot;100%&quot; border=&quot;0&quot;></div>
<div id=&quot;DialogBox&quot; class=&quot;BoxTrans&quot;>
<img src=&quot;Images/dialog.gif&quot; alt=&quot;&quot; height=&quot;100%&quot; width=&quot;100%&quot; border=&quot;0&quot;>
<div id=&quot;ScrollText&quot;>
<marquee><% RandomMessage() %> </marquee></div>
</div>

<!--Set-up the Content DIVS-->
<div id=&quot;MainContent&quot;>
<iframe allowtransparency=&quot;true&quot; name=&quot;ContentFrame&quot; src=&quot;Home.html&quot; frameborder=&quot;0&quot; height=&quot;100%&quot; width=&quot;100%&quot;></iframe>
</div>
<div id=&quot;SideContent&quot;>
<div id=&quot;SideContentTop&quot; style=&quot;position: absolute; top: 1px; left: 1px; width: 100%; height: 25%; visibility: hidden&quot;>
<img name=&quot;Computer&quot; src=&quot;&quot; alt=&quot;&quot; height=&quot;100%&quot; width=&quot;20%&quot; border=&quot;0&quot;>
<div id=&quot;SideContentTopText&quot; style=&quot;position: absolute; top: 1px; left: 1px; width: 100%; height: 100%; visibility: hidden&quot;></div>
</div>
<div id=&quot;SideContentMiddle&quot; style=&quot;position: absolute; top: 25%; left: 1px; width: 100%; height: 70%; visibility: hidden&quot;>
<iframe allowtransparency=&quot;true&quot; name=&quot;SideContentFrame&quot; src=&quot;&quot; frameborder=&quot;0&quot; height=&quot;100%&quot; width=&quot;100%&quot;></iframe>
</div>
<div id=&quot;SideContentBottom&quot; style=&quot;position: absolute; top: 95%; left: 1px; width: 100%; height: 5%; visibility: hidden&quot;></div>
</div>

<!--Set-up the Bottom Menu-->
<div id=&quot;BottomMenuBar&quot;>
<img src=&quot;Images/top-bar.gif&quot; alt=&quot;&quot; height=&quot;100%&quot; width=&quot;100%&quot; border=&quot;0&quot;>
<div id=&quot;BottomTextNav&quot;>
<div align=&quot;right&quot;>
<a href=&quot;Networking.html&quot; target=&quot;ContentFrame&quot; onClick=&quot;MakeMain();&quot;>Networking</a> | <a href=&quot; Login</a> | <a href=&quot;Support.html&quot; target=&quot;ContentFrame&quot; onClick=&quot;MakeMain();&quot;>Support</a> | <a href=&quot; Design</a> | <a href=&quot;AboutUs.html&quot; target=&quot;ContentFrame&quot; onClick=&quot;MakeMain();&quot;>About Us</a></div>
</div>
</div>
<div id=&quot;Logo&quot;>
<img src=&quot;Images/ShorelineLOGO.gif&quot; alt=&quot;&quot; height=&quot;100%&quot; width=&quot;100%&quot; border=&quot;0&quot;></div>
<div id=&quot;Cubes&quot;>
<img src=&quot;Images/background-boxes.gif&quot; alt=&quot;&quot; height=&quot;100%&quot; width=&quot;100%&quot; border=&quot;0&quot;></div>
</body>

</html>

Ok, I am getting an Expected Semi-Colon error on the line document.Computer.src = &quot;Tablet-PC.gif&quot;; in the function MakeSide, and when I click on any link, I get an Object expected error like it is not finding the functions. This however could be that it is an ASP page which may change the default scripting to VBScript. If this is the case, how do I declare that it is a javascript function and not VBScript within the onClick event?
 
In your functions, don't put the comment between the () and the {

For example this:

Code:
function MakeMain() //Switch to Main Content
 {
Should be this:
Code:
//Switch to Main Content
function MakeMain(){

Also, JavaScript is case sensitive. Change this:
Code:
If (document.getElementById(&quot;MainContent&quot;).style.visibility == &quot;visible&quot;)

To this:
if
Code:
 (document.getElementById(&quot;MainContent&quot;).style.visibility == &quot;visible&quot;)



Adam
while(ignorance==true){perpetuate(violence,fear,hatred);life=life-1};
 
Thanks for catching a couple of things I missed, the comments I just threw in there last minute before posting, just for readability. However, those if statements wouldn't have worked, so thanks for catching that. It still doesn't help with the main errors I'm having though.
 
Your error line may be off by one... look at the following line, you've got quotation marks inside quotation marks that aren't escaped.

Also, your cases should be as:

Code:
case &quot;Tablet&quot;:
 
Thanks, that was it, I'm not throwing either error anymore. However, something new is popping up...When I click on one of the side menu options, it should change the content around and make the SideContent containers visible and the MainContent hidden, but it's not doing this. It's keeping the MainContent visible. I can't check if it works the other way yet, because it starts with MainContent visible.
 
ok, I put an alert in front of the if statements in both of the functions like this:

alert(document.getElementById(&quot;MainContent&quot;).style.visibility);

also one for SideContent.

Both of the alert boxes are empty when they come up. Am I calling the element right?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top