Forum Moderators: open

Message Too Old, No Replies

Form Image Mouse Over

swapping the image

         

T Suresh Babu

6:51 am on Aug 13, 2002 (gmt 0)

10+ Year Member



Hai,

Any body knows how to swap the form image.
I tried

>> form name=”formname” onsubmit=”fnc()”
>> input type=”image” name=”imgname”
>> function fnc()
>> formname.imgname.src=”images/a.gif”;

It didnt work

-Suresh Babu

rewboss

7:03 am on Aug 13, 2002 (gmt 0)

10+ Year Member



In your <form> tag:

onsubmit="return fnc(this);"

Your JavaScript:

function fnc(form){
form.imgname.src='images/a.gif';
return true;
}

The onsubmit handler returns the value true to ensure that the form actually gets sent (this may be strictly unnecessary, but it's as well to cover all eventualities). The this keyword refers to the form; it saves you having to type document.formname every time (you missed out the "document" in your code) and means you can use the same function with different forms.

I haven't tested it, though; it assumes that the form button does actually have an src property -- I'm not certain that's the case. If not, try

document.imgname.src

and see if that works.