Wrox Programmer Forums
|
Javascript General Javascript discussions.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Javascript section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old March 19th, 2004, 07:38 PM
Friend of Wrox
 
Join Date: Sep 2003
Posts: 451
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via AIM to Ben Horne
Default GRRRRRRR!

Hi all,

I unfortunately am having another problem with another page:(. I opened it up before I started work on it and I got error messages right away:(. I think that, somehow, Course Technology(the publisher of my Dynamic HTML textbook) is trying to sabotage me as well as the other Dynamic HTML students. The horizontal lines are there just to (hopefully) isolate the problem

Anyways, here's the code:


<SCRIPT LANGUAGE="javascript">
<!--
Nav4 = (document.layers) ? 1:0;
IE4 = (document.all) ? 1:0;
ver4 =(Nav4 || IE4)?1:0;

function getNumber(el) {
    num=null;
    for (i=0; i<document.layers.length; i++) {
        theEl=document.layers[i];
        if (theEl.id==el) {
            num=i;
            break;
        }
    }
    return num;
}

function arrange() {
    nextY=document.layers[firstNum].pageY + document.layers[firstNum].document.height-10;
    for (i=firstNum+1; i<document.layers.length; i++) {
        theEl=document.layers[i];
        if (theEl.visibility != "hide") {
            theEl.pageY=nextY;
            nextY += theEl.document.height-10;
        }
    }
}

function init(){
    if (Nav4) {
        for (i=0; i<document.layers.length; i++) {
            theEl=document.layers[i];
            if (theEl.id.indexOf("Answer") != -1) {
                theEl.visibility="hide";
                theEl.expanded=false;
            }
        }
        arrange();
        }
    else {
        tempColl=document.all.tags("DIV");
        for (i=0; i<tempColl.length; i++) {
            if (tempColl(i).className == "answer") {
                tempColl(i).style.display="none";
                tempColl(i).expanded=false;
            }
        }
    }
}

function expand(el) {
    if (!ver4) return;
    if (IE4) {
        expandIE(el)
    }
    else {
        expandNav(el)
    }
}

function expand IE(el){
   theEl=eval(el+"Answer");
   if(theEl.style.display=="none"){
          theEl.style.display="block";
      theEl.expanded=true;
   }
   else{
        theEl.style.display="none";
          theEl.expanded="false
   }
}

function expandNav(el) {
    theEl=eval("document." + el + "Answer");
    if (theEl.visibility == "hide") {
        theEl.visibility="show";
        theEl.expanded=true;
    }
    else {
        theEl.visibility="hide";
        theEl.expanded=false;
    }
    arrange();
}

function showAll() {
    for (i=firstNum; i<document.layers.length; i++) {
        theEl=document.layers[i];
        theEl.visibility="show";
    }
}

with (document) {
    write("<STYLE TYPE='text/css'>");
    if (Nav4) {
        write(".question {position: absolute; visibility: hidden; left: 40px}");
        write(".answer {position: absolute; visibility: hidden; left: 50px; width: 90%}");
    }
    else {
        write(".question {position: relative; left: 40px}");
        write(".answer {display: none; position: relative; left: 50px; width: 90%}");
    }
    write("</STYLE>");
}

window.onload=init;
//-->
</SCRIPT>

HELP!



Ben Horne
Madison Area Technical College student
-------------------------
http://community.webshots.com/user/valerian114

Go there. I have a lot of awesome photos that I rendered myself

"A Person Who Claims To Be A Flash Junkie Isn't Really A Flash Junkie Unless He Can Prove It"
__________________
Ben Horne
-------------------------
I don\'t want to sound like I haven\'t made any mistakes. I\'m confident I have.

Most likely using FireFox and concocting my next Macromedia Flash project
Snibworks Forums Moderator

Welcome to the New Age
 
Old March 19th, 2004, 08:00 PM
Friend of Wrox
 
Join Date: Nov 2003
Posts: 1,285
Thanks: 0
Thanked 2 Times in 2 Posts
Default

Ya? And what happens when you run the code?

Please post any error and any other code that this script references to (if there is any). Does anything happen at all?

----------
---Snib---
----------

<><
 
Old March 19th, 2004, 08:04 PM
Friend of Wrox
 
Join Date: Sep 2003
Posts: 451
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via AIM to Ben Horne
Default

I get these errors

Line 65: Expected '('
Line 174: 'Nav4' is undefined

Quote:
quote:Originally posted by Snib
 Ya? And what happens when you run the code?

Please post any error and any other code that this script references to (if there is any). Does anything happen at all?

----------
---Snib---
----------

<><
Ben Horne
Madison Area Technical College student
-------------------------
http://community.webshots.com/user/valerian114

Go there. I have a lot of awesome photos that I rendered myself

"A Person Who Claims To Be A Flash Junkie Isn't Really A Flash Junkie Unless He Can Prove It"
 
Old March 19th, 2004, 08:16 PM
Friend of Wrox
 
Join Date: Nov 2003
Posts: 1,285
Thanks: 0
Thanked 2 Times in 2 Posts
Default

Which lines are these?

----------
---Snib---
----------

<><
 
Old March 19th, 2004, 08:31 PM
Friend of Wrox
 
Join Date: Sep 2003
Posts: 451
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via AIM to Ben Horne
Default

Line 65 is completely blank
Line 174 only has these characters: <!--

This doesn't make sense to me because the Nav4 statement is on Line 175

Here's Line 175: if (Nav4) {
    firstEl="oneQuestion";
    firstNum=getNumber(firstEl);
    showAll();
    arrange();

Quote:
quote:Originally posted by Snib
 Which lines are these?

----------
---Snib---
----------

<><
Ben Horne
Madison Area Technical College student
-------------------------
http://community.webshots.com/user/valerian114

Go there. I have a lot of awesome photos that I rendered myself

"A Person Who Claims To Be A Flash Junkie Isn't Really A Flash Junkie Unless He Can Prove It"
 
Old March 19th, 2004, 09:19 PM
Friend of Wrox
 
Join Date: Nov 2003
Posts: 1,285
Thanks: 0
Thanked 2 Times in 2 Posts
Default

I can't find the code you posted in your last post in the rest of your code.

Is the code you just posted before the previous code on your page?

Everything looks fine to me, unless you aren't giving all the info.

----------
---Snib---
----------

<><
 
Old March 19th, 2004, 10:07 PM
Friend of Wrox
 
Join Date: Sep 2003
Posts: 451
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via AIM to Ben Horne
Default

It's there,

You're not looking hard enough


Quote:
quote:Originally posted by Snib
 I can't find the code you posted in your last post in the rest of your code.

Is the code you just posted before the previous code on your page?

Everything looks fine to me, unless you aren't giving all the info.

----------
---Snib---
----------

<><
Ben Horne
Madison Area Technical College student
-------------------------
http://community.webshots.com/user/valerian114

Go there. I have a lot of awesome photos that I rendered myself

"A Person Who Claims To Be A Flash Junkie Isn't Really A Flash Junkie Unless He Can Prove It"
 
Old March 19th, 2004, 10:25 PM
Friend of Wrox
 
Join Date: Nov 2003
Posts: 1,285
Thanks: 0
Thanked 2 Times in 2 Posts
Default

According to the original code, 'firstNum' is never defined.

I used Find(on this page) and it came up with nothing...

You must be leaving something out...

----------
---Snib---
----------

<><
 
Old March 25th, 2004, 04:30 PM
Registered User
 
Join Date: Mar 2004
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default

function expand IE(el){
theEl=eval(el+"Answer");
if(theEl.style.display=="none"){
         theEl.style.display="block";
     theEl.expanded=true;
}
else{
        theEl.style.display="none";
         theEl.expanded="false <--- Can this be the cause of your error?
}
}
 
Old April 2nd, 2004, 02:30 PM
Friend of Wrox
 
Join Date: Sep 2003
Posts: 451
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via AIM to Ben Horne
Default

Yeah,

I redid the entire page script and I did not come up with that error. However, I'm still getting errors with the script. I opened the page code in Interdev and this is what it highlighted

expand('one')

The entire code is in one of my earlier posts(I think)

Quote:
quote:Originally posted by patschm
 function expand IE(el){
theEl=eval(el+"Answer");
if(theEl.style.display=="none"){
         theEl.style.display="block";
     theEl.expanded=true;
}
else{
        theEl.style.display="none";
         theEl.expanded="false <--- Can this be the cause of your error?
}
}
Ben Horne
Madison Area Technical College student
-------------------------
http://community.webshots.com/user/valerian114

Go there. I have a lot of awesome photos that I rendered myself

"A Person Who Claims To Be A Flash Junkie Isn't Really A Flash Junkie Unless He Can Prove It"









Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.