PDA

View Full Version : Caching slideshow, button type=image question


gorilla1
08-12-2002, 07:35 PM
Another question on the dynamic drive caching slideshow. It is using text button fields. At this address:

I have tried an image on the back button instead of text. To do so, I changed the form and one line of the script: specifically, I commented out this line:
// document.SlideShow.Previous.disabled = (NextSlide == 0);

However, when you hit the back button on the slideshow control after this change has been made (as it is at the url I gave), the script throws up the prior image momentarily, then goes to the first slide in the series and resumes from there. I can't see why this is the case. Can anyone spot why using the image button type trips the script up (I realize it may have to do with the line I commented, but I can't see why).

G

beetle
08-12-2002, 08:12 PM
The default action for an input type=image is to submit it's form. You need to cancel that action if you intend to use it for anything else<inpute type="image" src="button.gif" onClick="function();return false;" />

gorilla1
08-12-2002, 08:48 PM
beetle,

Exactly right! That did it. Thanks!

G

gorilla1
08-12-2002, 09:56 PM
Well, it worked beautifully in IE, but no luck in. NS4. Is there some special approach needed with respect to onClick="Function();return false;" under NS?

G

beetle
08-12-2002, 10:05 PM
Um. Not sure. I spend about -1 brain-cycles-per-day understanding NS4.x soooo my only guess is this: You can't cancel the default action of the input type=image

Try a simple test like this<HTML>
<HEAD>

<script language="javascript" type="text/javascript">
function verify(val)
{
return (val == 1) ? true : false;
}
</script>

</HEAD>
<BODY>

<form onSubmit="return verify(0)" action="http://www.disney.com">
<input type="submit" value="Test False">
</form>

<form onSubmit="return verify(1)" action="http://www.disney.com">
<input type="submit" value="Test True">
</form>

</BODY>
</HTML>
If both of these forms send you to www.disney.com, then you can't cancel the form submission. Also, try it with 'image' inputs instead of regular 'submit' inputs...like this: <form action="http://www.disney.com">
<input type="image" src="pic.gif" alt="Test False" title="Test False" onclick="alert('Form should not submit'); return false;">
</form>

<form action="http://www.disney.com">
<input type="image" src="pic.gif" alt="Test True" title="Test True" onclick="alert('Form should submit'); return true;">
</form>