471,316 Members | 1,693 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,316 software developers and data experts.

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="JavaScript" 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,287,92" HREF = "#"
OnClick="alert(alert_msg);return false;"></a>
************************************************** *******
Can anybody point out the error of my ways?

Thanks
Dave

Jul 23 '05 #1
3 1927
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

Jul 23 '05 #2
Lee
dg*****@erols.com said:

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="JavaScript" 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,287,92" HREF = "#"
OnClick="alert(alert_msg);return false;"></a>
************************************************* ********
Can anybody point out the error of my ways?


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

Jul 23 '05 #3
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

Jul 23 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

11 posts views Thread by Vincent van Beveren | last post: by
9 posts views Thread by Nathan Sokalski | last post: by
7 posts views Thread by trey.bason | last post: by
1 post views Thread by Jeff | last post: by
pbmods
1 post views Thread by pbmods | last post: by
reply views Thread by DamienS | last post: by
reply views Thread by rosydwin | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.