USEMAP with separate map files and database


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.
Who is Participating?
webwomanConnect With a Mentor Commented:
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... ;-) )
Looks okay to me. Are you sure that the map is correct too?

<img src="myimage.gif" usemap="canada.htm#canada" ISMAP>
Does it work for you, if both the map and image are in the same file?

Cloud Class® Course: Microsoft Azure 2017

Azure has a changed a lot since it was originally introduce by adding new services and features. Do you know everything you need to about Azure? This course will teach you about the Azure App Service, monitoring and application insights, DevOps, and Team Services.

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.
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.
balabasterAuthor Commented:
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 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?
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?
balabasterAuthor Commented:
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!

balabasterAuthor Commented:
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.
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!
balabasterAuthor Commented:
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.
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.