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. Advertisements

  2. Robert Baer

    Paul Guest

    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. Advertisements

  3. Robert Baer

    Robert Baer Guest

    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. Advertisements

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.