FIXED!!! - javascript and HTML help needed

acejj26

Senior member
Dec 15, 1999
886
0
0
okay guys, this should be fairly simple...i think i'm just doing something silly that i'm overlooking. what i'm trying to do is when an image is clicked on a page, i want it to fire off a little javascript. when i have:

<input type="button" onClick="move(this.form.list2,this.form.list1)" id=up name=up value="up">

the script runs fine. however, when i have:

<img src="\images\arrowup1.gif" onClick="move(this.form.list2,this.form.list1)" id=up name=up value=up>

i get the following error:

A runtime error has occurred
Error: 'this.form.list1' is not an object

i don't want input type = "image" because that submits the form and i don't want to do that

any help?? i'm not sure why this won't work
 

joinT

Lifer
Jan 19, 2001
11,172
0
0
did you try this exactly ?
<input type="image" src=="\images\arrowup1.gif" onClick="move(this.form.list2,this.form.list1)" id=up name=up value="up">

cuz if the type isn't submit - i don't understand why it should submit when you click on it :(

 

acejj26

Senior member
Dec 15, 1999
886
0
0
input type="image" is the same as input type="submit" only with a specified graphic instead of the gray submit button.....i don't want to submit a form when i click on the image...i just want it to fire off the javascript. i don't understand why it returns the error on clicking on a picture as opposed to clicking on a button.
 

jpsj82

Senior member
Oct 30, 2000
958
0
0
do this

< a href="javascript:function()" ><img src="pic1.gif">< /a >

that should work just remove the spaces.

edit: forum doesn't like html.
 

acejj26

Senior member
Dec 15, 1999
886
0
0
okay, guys, i got it...thanks.....here was the problem

instead of the onclick being "this.form.list1....", it had to be "document.formname.list1..." because the script didn't recognize what "this" and the "form" was.