Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win


USEMAP with separate map files and database

Posted on 2002-05-21
Medium Priority
Last Modified: 2010-04-09

I'm trying to load maps from a separate map file for maintenance purposes.

contents of demo.htm file
<img src="myimage.gif" usemap="canada.htm#canada">

contents of canada.htm file
<map name=canada>
<area name=BritishColumbia shape="rect" coords="0, 0, 250, 250" href="bc.htm">
<area name=Alberta shape="rect" coords="0, 250, 250, 250">
etc etc etc

can someone PLEASE explain to me why this doesn't work.  Every website I've been to has something similar to this as an example.  Is this functionality that has been dropped from the DOM in recent releases?

I have an ASP page which is built from the content of a table in a database and need to be able to pull the relevant map file for the image.  i.e. if someone selects USA, then I need it to pull the map as well as the coordinate file from the database.  I can get it to build the page without any problems, it's just that when I do this, my imagemaps won't work.

Thanks for any help.
Question by:balabaster
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 4
  • 2
  • +1
LVL 22

Expert Comment

ID: 7026487
Looks okay to me. Are you sure that the map is correct too?

<img src="myimage.gif" usemap="canada.htm#canada" ISMAP>
LVL 22

Expert Comment

ID: 7026491
Does it work for you, if both the map and image are in the same file?


Expert Comment

ID: 7026588
When I was trying to do the same (and also discussed the problem with other coders), I came to a conclusion that it's impossible.

However when placed in one file, it works just fine.
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

LVL 19

Expert Comment

ID: 7026860
You can do it as an include, that would work.

But try it as a TEXT file, not HTML. Rename the file to canada.txt and see what happens.

Author Comment

ID: 7028249
CJ S:  Yes the image and the map both work in the same file.  The only thing is, I have 10 countries in the database currently and would need to include 10 image maps in my html, not something I want to do, as in 2 weeks, I am likely to have 100 countries, and 100 maps, and I don't want 100 maps in my HTML, it's a waste of download time.


Leveret: I'm rapidly coming to the same conclusion.  Of course, the HTML 3.2 Specification dictates that it should work, but I guess Microsoft & Netscape in their infinite wisdom decided that design specifications aren't important in this world anyway.  Who am I to argue? I'm just a lowly programmer who just has to work around their shortcomings.


WebWoman: Okay, I understand the include, I can do that...how do I get it to determine which page to include by getting the info from the database?  I've been trying to use this work around, but I can't figure out how.

The following code generates the correct string, but then it promptly decides to dump that literal into the HTML instead of including the file.

Response.Write "<!-- #include virtual="& oRec("MapFile") &" -->"

I understand why it does this, response.write tells it to write that into the HTML, it doesn't tell it to include it as #include does.  Any clues how I would make it include dynamically?
LVL 19

Accepted Solution

webwoman earned 200 total points
ID: 7028294
You can't. You can use an if/elseif construction to check through a list of various includes, but you can't use a variable name as the include.

You can store the map info in the datbase, code and all (it's just text, after all), and insert THAT instead of using an include. That works too.

So instead of the include you'd use
<%= rs("mapinfo") %>
where you want the map info to show up.
(response.write is too confusing for me... ;-) )
LVL 19

Expert Comment

ID: 7028300
Of course, if you're going to pull that info from a database, you need to have a unique number for the record (or some unique identifier) AND you need to pass that to the map page so you know what to pull from the database.

Have you done that before? And did you try changing the map info to a TXT file extension?

Author Comment

ID: 7028341
webwoman: yeppers, been there done that...the txt file extension gives me the same aggravation.

With regards to putting the map coordinate info *in* the database, I'd already thought about this, but can't come up with a satisfactory way of putting the info in the database...I don't know if you've seen a coordinate file for a country like the U.S., but it's a mile long.  Putting it into the database is almost as big a headache as trying to get imagemaps in separate files to work.  If this is the only way to do it, then I guess I'm gonna go that route...eek.

Any more ideas would be most welcome.  Why oh why can't software providers implement *anything* on spec?  Anybody working for Microsoft & Netscape.  TAKE HEED TO THAT!


Author Comment

ID: 7028529
Well, I guess technically the answer is excellent, although it sucks that this is the only way to do it, so well done.

I've loaded the contents of all my map files into my database and am doing it that way, grrrr.  It works though.

Thanks anyway.
LVL 19

Expert Comment

ID: 7028577
I know what you mean... I wish they'd come up with a better way too. I've got entire press releases, with links to pics, tables, tons of HTML code, in my database. It sure would be a whole lot easier if I could just put the include file name there...

Thanks for the A!

Author Comment

ID: 7028580
Well you would think that you wouldn't need to load down your database with all that data.  Maybe this hasn't been presented to Microsoft/Netscape yet.

No problems with the (A) I hope ;)

Talk to you again possibly.

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article describes how to create custom column layout styles for Bootstrap. The article uses 5 columns to illustrate the concept, but the principle can be extended to any number of columns.
Building a website can seem like a daunting task to the uninitiated but it really only requires knowledge of two basic languages: HTML and CSS.
In this tutorial viewers will learn how to embed videos in a webpage using HTML5. Ensure your DOCTYPE declaration is set to HTML5: "<!DOCTYPE html>": Use the <video> tag to insert a video. Define the src as the URL of your video; this is similar to …
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

604 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question