473,395 Members | 1,978 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

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

Clicking Image Map Highlights Row

Hello,

I have an image map of a subdivision and each section of land in the
subdivision has a lot number on it. Below the image map I have a table
with details about each lot (eg Lot Number, Lot Size, Lot Price
ect...)

I would really like a way so the user can click on the image map and
the corresponding row below the image will be highlighted.

The user clicks on a new row and the previous row goes back to its
original color and the new row is highlighted.

Is the possible? If it is and can someone please point me in the right
direction on how you would do this?
Jul 23 '05 #1
10 3541
sling blade wrote:
Hello,

I have an image map of a subdivision and each section of land in the
subdivision has a lot number on it. Below the image map I have a table
with details about each lot (eg Lot Number, Lot Size, Lot Price
ect...)
I would really like a way so the user can click on the image map and
the corresponding row below the image will be highlighted.
The user clicks on a new row and the previous row goes back to its
original color and the new row is highlighted.
Is the possible? If it is and can someone please point me in the right
direction on how you would do this?


Will something like this work for you? Try this example by clicking
around on the nonexistent image. You'll find the sensitive areas pretty
quickly.

- Each table row that will be highlighted needs a unique ID.
- Imagemap areas are clickable, call the row highlight function with the
correct row number in the imagemap click event.
- The buttons demonstrate the function calls.

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>

<head>
<title>Untitled</title>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=ISO-8859-1">

<script type="text/javascript">
function change(n){
clearallrows()
document.getElementById('row'+n).style.backgroundC olor='#FFAABB';
}
function clearallrows(){
for (var n=1;n<5;n++){
document.getElementById('row'+n).style.backgroundC olor='#FFFFFF';
}
}
</script>
</head>
<body>
<input type="button" onclick="change(1)" value="1">
<input type="button" onclick="change(2)" value="2">
<input type="button" onclick="change(3)" value="3">
<input type="button" onclick="change(4)" value="4">
<input type="button" onclick="clearallrows()" value="no highlights">
<p>Click on one of the planets:</p>
<img src ="planets.gif" width ="245" height ="226" alt="test" usemap
="#imagemap">
<map NAME="imagemap">
<area shape="rect" coords="20,25,84,113" onclick="change(1)" href ="#">
<area shape="polygon" coords="90,25,162,26,163,96,89,25,90,24"
onclick="change(2)" href ="#">
<area shape="circle" coords="130,114,29" onclick="change(3)" href ="#">
<area shape="rect" coords="19,156,170,211" onclick="change(4)" href ="#">
</map
</MAP>
<table border=1 align=center>
<caption>Statistics</caption>
<th>Year</th>
<th>Team</th>
<tr id='row1'>
<td align=right>1930</td>
<td align=right>Detroit</td>
</tr>
<tr id='row2'>
<td align=right>1933</td>
<td align=right>Detroit</td>
</tr>
<tr id='row3'>
<td align=right>1934</td>
<td align=right>Detroit</td>
</tr>
<tr id='row4'>
<td align=right>1935</td>
<td align=right>Detroit</td>
</tr>
</table>
</body>
</html>

Mike
Jul 23 '05 #2
mscir wrote:
[...]
<map NAME="imagemap">
<area shape="rect" coords="20,25,84,113" onclick="change(1)" href ="#">


Using an empty anchor causes the page to scroll to the top when
the anchor is clicked. To stop this happening, have the onclick
return false:

<area ... onclick="change(1);return false;" href="#">

--
Rob
Jul 23 '05 #3
Great! Thanks that is exacty what I needed.

Thank you Mike and Rob!

Jul 23 '05 #4
One other thing, in the clearallrows function is there a way to have it
loop through each row dynamically rather than a fix number?
eg in VB
For Each Row in Table
change backcolor...
Next Row

The reason is that the table will lilely be generated from a database.
As the lots are sold then the information for that lot will not be
generated in the table any more.

So the total number of rows is likely to change over time.

Any ideas on this?

Jul 23 '05 #5
sc******@hotmail.com wrote:
One other thing, in the clearallrows function is there a way to have it
loop through each row dynamically rather than a fix number?
eg in VB
For Each Row in Table
change backcolor...
Next Row

The reason is that the table will lilely be generated from a database.
As the lots are sold then the information for that lot will not be
generated in the table any more.

So the total number of rows is likely to change over time.

Any ideas on this?


for (var i=0;i<tableLength;i++){
......
}

Where tableLength is a variable that is dynamically inserted by the same
language/script that dynamically generates the table.

--
Randy
comp.lang.javascript FAQ - http://jibbering.com/faq & newsgroup weekly
Jul 23 '05 #6
The language that will generate the table is asp.net.

The first idea I can think of to do this is to have a count function in
the SQL statement count the number of rows returned and then place this
amount in a session variable.

Do you know how you assign a javascript variable to a asp.net session
variable or any other dynamic variable?

Thanks for your help.

Jul 23 '05 #7
RobG wrote:
mscir wrote:
[...]
<map NAME="imagemap">
<area shape="rect" coords="20,25,84,113" onclick="change(1)" href ="#">


Using an empty anchor causes the page to scroll to the top when
the anchor is clicked. To stop this happening, have the onclick
return false:

<area ... onclick="change(1);return false;" href="#">


Nice fix, thanks!
Mike
Jul 23 '05 #8
RobG wrote on 13 feb 2005 in comp.lang.javascript:
<area ... onclick="change(1);return false;" href="#">


<area ... onclick="change(1);" nohref>
--
Evertjan.
The Netherlands.
(Replace all crosses with dots in my emailaddress)

Jul 23 '05 #9
sc******@hotmail.com wrote:
One other thing, in the clearallrows function is there a way to have it
loop through each row dynamically rather than a fix number?


Yes

If you give the table an id, the rows collection is returned
by:

var theRows = document.getElementById('tableID').rows;

To keep the users of older IE happy, do some feature testing and
add a document.all method (untested):

if (document.getElementById) {
var theRows = document.getElementById('tableID').rows;
} else if (document.all) {
var theRows = document.all('tableID').rows;
}

You can loop through the rows thusly:

for (var i=0; i<theRows.length; i++) {
theRows[i] ....
}
--
Rob
Jul 23 '05 #10
Awesome!

Thanks for all your help!

Jul 23 '05 #11

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Billy Jacobs | last post by:
I have a treeview control in my application. If I right- click a node, it highlights the node but does not set it to be selected. If you move off the control it highlights the previously selected...
4
by: Ice Man | last post by:
Hi all How Can I submit a form by clicking on an image instead of the submit button? Thanks
1
by: Phoebe. | last post by:
Hi, Good Day! I've a image & would like to direct it to another webform by clicking it. <input class="imageGo" src="images/go.gif" ondblclick="EnterPage" runat="server" type="image"> Above...
6
by: pmud | last post by:
Hi, I have created a very simple ASP.NET application which has a couple of ImageButtons which go to different SQL reports on clicking them. I have used Response.Redirect to send the user to the ...
7
by: darkk | last post by:
sorry if this is not the right place to post this I was wondering how I could highlight everything in a textbox just by clicking on it. example: textbox1 has "0" as text, I want to click(it...
3
by: vj | last post by:
how to change images based on action. Even clicking changed images should do respective actions. and while displaying only one image at a time sholud get displayed. I am using three images for a...
1
by: saikatbose2005 | last post by:
Hi, Ineed some help from anyone regarding an issue I'm facing. I've created an image dynamically on clicking a button. What I inetend to do is when I click on the created image it will popup a...
1
by: Kirthikaiitm | last post by:
Hi, I have a image button (APPLY) On clicking apply button how to move the content from textbox to another textarea. I wrote the code in JScript. But once i click APPLY button the form is...
10
by: Benny | last post by:
I am wondering if anyone has a simple approach to detecting the location of boxes and/or lines on an image. For example, if I have an image of a form, and want to find out where all of the boxes...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

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.