Hello group, I can’t seem to get this work. It’s supposed to do this:
* user clicks on image and the X and Y coords are concatenated into a string as “X,Y,” etc.* Then, the value is appended to the value in the text area.
So for example, if the user clicks in 3 different spots, the text area will have something simalar to:
124,71,135,78,199,92,
But what’s happening is that every time the user clicks, the form seems to ‘submit’ and the text area clears out. I know that the default event of the input image type is submit,
but I can’t even get it to work using the image with a href tag and “OnClick”
Please help.
Thanks.
Here’s the code:
<html>
<head>
<title>Test</title>
<meta http-equiv=”Content-Type” content=”text/html; charset=iso-8859-1″>
<script language=”JavaScript”>
<!–
// <!–
function detect_mouse(field,x,y) {
var fv = field.value;
var test = fv + x + “,” + y + “,”;
field.value = fv + x + “,” + y + “,”;
}
//–>
</script>
</head>
<body bgcolor=”#CCCCCC” leftmargin=”0″ topmargin=”0″ marginwidth=”0″ marginheight=”0″>
<form>
<input type=”image” src=”image/C1.gif” width=”300″ height=”300″ onClick=”detect_mouse(this.form.TheTextArea,event.clientX,event.clientY);”>
<br>
<textarea name=”TheTextArea” cols=”50″ rows=”15″></textarea>
</form>
</body>
</html>