|
-
Jul 10th, 2005, 12:23 PM
#1
Thread Starter
Frenzied Member
Image map doesn't work with javascript function
I've created a simple function that should update a textfield based on an image map. For some reason this is not working and I can't find any problems with the code. If you can help out, please do.
The code is as follows:
Code:
<html>
<head>
<title>Mapping Example</title>
<script language="JavaScript" type="text/javascript">
function update(t)
{
document.form1.text1.value = t;
}
</script>
</head>
<body>
<map name="map1>
<area shape="rect" coords="0,0,100,100" onClick="update('left');">
<area shape="rect" coords="20,0,40,40" onClick="update('right');">
</map>
<h1>Image map example</h1>
<hr>
<img src="mateintwo.jpg" usemap="#map1">
</hr>
<form name="form1">
<input type="text" name="text1">
</form>
</body>
</html>
-
Jul 10th, 2005, 07:02 PM
#2
Re: Image map doesn't work with javascript function
By my standards, the code is horribly broken, but that's a different issue.
If I just put the missing quote at the end of the name attribute of the map tag, the code works for me in Firefox.
All the buzzt
 CornedBee
"Writing specifications is like writing a novel. Writing code is like writing poetry."
- Anonymous, published by Raymond Chen
Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.
-
Jul 10th, 2005, 11:27 PM
#3
Thread Starter
Frenzied Member
Re: Image map doesn't work with javascript function
Can't believe I missed that, but thank you.
 Originally Posted by CornedBee
By my standards, the code is horribly broken, but that's a different issue.
I'm a beginner to this, could you explain?
-
Jul 11th, 2005, 04:47 AM
#4
Re: Image map doesn't work with javascript function
1) You use the HTML pseudo-DOM for accessing elements.
2) You use name instead of id.
3) You miscapitalize onclick.
4) You have insufficient separation of structure and behaviour. (But that can be excused since this is just an example.)
That aside, an image map is, by basic principle, completely inaccessible to any non-graphical browsers.
All the buzzt
 CornedBee
"Writing specifications is like writing a novel. Writing code is like writing poetry."
- Anonymous, published by Raymond Chen
Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.
-
Jul 11th, 2005, 11:32 AM
#5
Thread Starter
Frenzied Member
Re: Image map doesn't work with javascript function
Looks like I need a new book!
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|