JavaScript Alert problem in imagemap

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • dgmoore@erols.com

    #1

    JavaScript Alert problem in imagemap

    Hello -

    I'm having trouble with JavaScript alerts in an imagemap. The mapped
    areas are cells in a table, and the alerts display info related to the
    cell that is clicked. The problem is that, even though the source html
    is correct, the alert messages that are displayed appear to be random,
    i.e., the alert for row 10 appears when row 3 is clicked, etc. On some
    long tables, the same alert message is displayed for (nearly) every row
    even though the html contains the correct message for each row.

    It looks like, among other things, perhaps the alert is not being
    "cleared" consistently after after being invoked, and when the next row
    is clicked the info from the preceding choice is displayed again.

    I'm using
    *************** *************** *************** **********
    <script language="JavaS cript" type="text/javascript">
    <!--
    var alert_msg = "";
    alert_msg +="Line 1";
    alert_msg +="\nLine 2";
    alert_msg +="\nLine 3";
    // -->
    </script>

    <area SHAPE+"RECT" COORDS="0,62,28 7,92" HREF = "#"
    OnClick="alert( alert_msg);retu rn false;"></a>
    *************** *************** *************** ************
    Can anybody point out the error of my ways?

    Thanks
    Dave

  • dgmoore@erols.com

    #2
    Re: JavaScript Alert problem in imagemap

    As Rosanne RosannaDanna used to say, "...Never mind". I failed to index
    the successive alert_msg's in the script, so each one was overwriting
    the preceding one and they all wound up being the same. I changed var
    alert_msg to var alert_msg & N, where N is incremented each time.
    Problem solved.

    Thanks anyway...
    Dave

    Comment

    • Lee

      #3
      Re: JavaScript Alert problem in imagemap

      dgmoore@erols.c om said:[color=blue]
      >
      >Hello -
      >
      >I'm having trouble with JavaScript alerts in an imagemap. The mapped
      >areas are cells in a table, and the alerts display info related to the
      >cell that is clicked. The problem is that, even though the source html
      >is correct, the alert messages that are displayed appear to be random,
      >i.e., the alert for row 10 appears when row 3 is clicked, etc. On some
      >long tables, the same alert message is displayed for (nearly) every row
      >even though the html contains the correct message for each row.
      >
      >It looks like, among other things, perhaps the alert is not being
      >"cleared" consistently after after being invoked, and when the next row
      >is clicked the info from the preceding choice is displayed again.
      >
      >I'm using
      >************** *************** *************** ***********
      ><script language="JavaS cript" type="text/javascript">
      ><!--
      >var alert_msg = "";
      >alert_msg +="Line 1";
      >alert_msg +="\nLine 2";
      >alert_msg +="\nLine 3";
      >// -->
      ></script>
      >
      ><area SHAPE+"RECT" COORDS="0,62,28 7,92" HREF = "#"
      >OnClick="alert (alert_msg);ret urn false;"></a>
      >************** *************** *************** *************
      >Can anybody point out the error of my ways?[/color]

      You haven't shown us anything that would make the alert message
      different for different areas. Do different areas display different
      variables?

      Comment

      • dgmoore@erols.com

        #4
        Re: JavaScript Alert problem in imagemap

        Yes - the data to be displayed for each area is different, but since I
        hadn't subscripted the alert message variable, when the page loaded it
        was being processed from beginning to end so all of the messages
        displayed the text of the last message processed. I changed it so each
        successive message variable is different (msg1, msg2, msg3, etc.) and
        this fixed the glitch.

        Thanks
        Dave

        Comment

        Working...