Coding problem

Discussion in 'Computer Information' started by Robert Baer, Aug 22, 2013.

  1. Robert Baer

    Robert Baer Guest

    The following code "works" in a strange way; see the comments for
    details.
    1) why is that document.write necessary for operation?
    2) why doesn't the altered variable "title" remain changed?
    3) i would like to change displayed page, based on map visits

    Help? Comments?


    <SCRIPT type="text/javascript">
    // <img id="page" src=title alt="Codatron page 1">
    // src="images/CodatronP1.png"
    var title="images/CodatronP1.png";
    var dir=-1;
    var num=3;
    function incrPage(dir,title)
    {
    num=title.substr(16,1).valueOf();
    if (dir===-1)
    {
    num=num-1;
    if (num===0) {num=7;}
    }
    else
    {
    num=num+1;
    if (num===8) {num=1;}
    }
    title=title.substr(0,16)+num+title.substr(17);
    document.write("###"+title+"*");
    // above correct at page 7 being "previous" to page 1 (sequence 1,2,,7,1
    etc)
    // *NOTE* the document.write MUST exist for the map visits to work ???
    }
    incrPage(dir,title);
    // document.write("***"+title+"* *#");
    // above is wrong, with title equal to unchanged initial def

    // document.getElementById("page").innerHTML=title;
    </script>

    <div>
    <img src="ShuttleN.png" alt="Select" usemap="#PageSelect"
    </div>
    <div>
    <!-- visiting mapped areas give "###-1*" or "###1*" in new screen -->
    <map id="images/CodatronP5.png" name="PageSelect">
    <area shape="rect" alt="Minus" coords="65,0,135,35"
    src="N.PNG" onMouseover="incrPage(-1,id)" >
    <area shape="rect" alt="Plus" coords="590,0,668,35"
    src="P.PNG" onMouseover="incrPage(1,id)" >
    <area shape="default" nohref="nohref" alt="" >
    </map>
    </div>

    <!-- display page one; would like to change that based on map visits -->
    <div class=" container_24">
    <div class="wrapper">
    <img id="page" src="images/CodatronP1.png" alt="Page">
    </div>
    </div>
    Robert Baer, Aug 22, 2013
    #1
    1. Advertising

  2. Robert Baer

    Paul Guest

    Robert Baer wrote:
    > The following code "works" in a strange way; see the comments for
    > details.
    > 1) why is that document.write necessary for operation?
    > 2) why doesn't the altered variable "title" remain changed?
    > 3) i would like to change displayed page, based on map visits
    >
    > Help? Comments?
    >
    >
    > <SCRIPT type="text/javascript">
    > // <img id="page" src=title alt="Codatron page 1">
    > // src="images/CodatronP1.png"
    > var title="images/CodatronP1.png";
    > var dir=-1;
    > var num=3;
    > function incrPage(dir,title)
    > {
    > num=title.substr(16,1).valueOf();
    > if (dir===-1)
    > {
    > num=num-1;
    > if (num===0) {num=7;}
    > }
    > else
    > {
    > num=num+1;
    > if (num===8) {num=1;}
    > }
    > title=title.substr(0,16)+num+title.substr(17);
    > document.write("###"+title+"*");
    > // above correct at page 7 being "previous" to page 1 (sequence 1,2,,7,1
    > etc)
    > // *NOTE* the document.write MUST exist for the map visits to work ???
    > }
    > incrPage(dir,title);
    > // document.write("***"+title+"* *#");
    > // above is wrong, with title equal to unchanged initial def
    >
    > // document.getElementById("page").innerHTML=title;
    > </script>
    >
    > <div>
    > <img src="ShuttleN.png" alt="Select" usemap="#PageSelect"
    > </div>
    > <div>
    > <!-- visiting mapped areas give "###-1*" or "###1*" in new screen -->
    > <map id="images/CodatronP5.png" name="PageSelect">
    > <area shape="rect" alt="Minus" coords="65,0,135,35"
    > src="N.PNG" onMouseover="incrPage(-1,id)" >
    > <area shape="rect" alt="Plus" coords="590,0,668,35"
    > src="P.PNG" onMouseover="incrPage(1,id)" >
    > <area shape="default" nohref="nohref" alt="" >
    > </map>
    > </div>
    >
    > <!-- display page one; would like to change that based on map visits -->
    > <div class=" container_24">
    > <div class="wrapper">
    > <img id="page" src="images/CodatronP1.png" alt="Page">
    > </div>
    > </div>


    You need a Javascript programming group. And the two I looked
    at, the noise level is pretty high (lots of adverts for
    prescription drugs). It would be pretty difficult to get
    a hearing in a group like that.

    Maybe you can find the odd university course note on Javascript.

    http://www.ohio.edu/technology/training/upload/Java-Script-Reference-Guide.pdf

    Paul
    Paul, Aug 22, 2013
    #2
    1. Advertising

  3. Robert Baer

    Robert Baer Guest

    Paul wrote:
    > Robert Baer wrote:
    >> The following code "works" in a strange way; see the comments for
    >> details.
    >> 1) why is that document.write necessary for operation?
    >> 2) why doesn't the altered variable "title" remain changed?
    >> 3) i would like to change displayed page, based on map visits
    >>
    >> Help? Comments?
    >>
    >>
    >> <SCRIPT type="text/javascript">
    >> // <img id="page" src=title alt="Codatron page 1">
    >> // src="images/CodatronP1.png"
    >> var title="images/CodatronP1.png";
    >> var dir=-1;
    >> var num=3;
    >> function incrPage(dir,title)
    >> {
    >> num=title.substr(16,1).valueOf();
    >> if (dir===-1)
    >> {
    >> num=num-1;
    >> if (num===0) {num=7;}
    >> }
    >> else
    >> {
    >> num=num+1;
    >> if (num===8) {num=1;}
    >> }
    >> title=title.substr(0,16)+num+title.substr(17);
    >> document.write("###"+title+"*");
    >> // above correct at page 7 being "previous" to page 1 (sequence
    >> 1,2,,7,1 etc)
    >> // *NOTE* the document.write MUST exist for the map visits to work ???
    >> }
    >> incrPage(dir,title);
    >> // document.write("***"+title+"* *#");
    >> // above is wrong, with title equal to unchanged initial def
    >>
    >> // document.getElementById("page").innerHTML=title;
    >> </script>
    >>
    >> <div>
    >> <img src="ShuttleN.png" alt="Select" usemap="#PageSelect"
    >> </div>
    >> <div>
    >> <!-- visiting mapped areas give "###-1*" or "###1*" in new screen -->
    >> <map id="images/CodatronP5.png" name="PageSelect">
    >> <area shape="rect" alt="Minus" coords="65,0,135,35"
    >> src="N.PNG" onMouseover="incrPage(-1,id)" >
    >> <area shape="rect" alt="Plus" coords="590,0,668,35"
    >> src="P.PNG" onMouseover="incrPage(1,id)" >
    >> <area shape="default" nohref="nohref" alt="" >
    >> </map>
    >> </div>
    >>
    >> <!-- display page one; would like to change that based on map visits -->
    >> <div class=" container_24">
    >> <div class="wrapper">
    >> <img id="page" src="images/CodatronP1.png" alt="Page">
    >> </div>
    >> </div>

    >
    > You need a Javascript programming group. And the two I looked
    > at, the noise level is pretty high (lots of adverts for
    > prescription drugs). It would be pretty difficult to get
    > a hearing in a group like that.
    >
    > Maybe you can find the odd university course note on Javascript.
    >
    > http://www.ohio.edu/technology/training/upload/Java-Script-Reference-Guide.pdf
    >
    >
    > Paul

    Thanks! That is a decent presentation and rather clear for what they
    cover.
    Then there is the JavaScript online tutorial
    http://www.w3schools.com/js/default.asp which seems to cover
    everything,with working examples.
    But both only cover basics and not a "package".
    Robert Baer, Aug 22, 2013
    #3
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Peter Stewart

    Thunderbird character coding

    Peter Stewart, Jul 1, 2004, in forum: Firefox
    Replies:
    0
    Views:
    1,252
    Peter Stewart
    Jul 1, 2004
  2. Galaxy
    Replies:
    1
    Views:
    751
    Moz Champion
    Jul 16, 2004
  3. Mr. Smiley

    Re: HTML Coding Problem

    Mr. Smiley, Aug 28, 2003, in forum: Computer Support
    Replies:
    1
    Views:
    442
    Bad Little Kyle
    Aug 28, 2003
  4. Rosco

    Re: HTML Coding Problem

    Rosco, Aug 29, 2003, in forum: Computer Support
    Replies:
    2
    Views:
    446
    Rosco
    Sep 4, 2003
  5. Ethan James

    Listbox coding problem

    Ethan James, Apr 9, 2009, in forum: General Computer Support
    Replies:
    1
    Views:
    1,345
    jbuyers
    Jun 22, 2009
Loading...

Share This Page