View Full Version : Image Java Prompt


tarq
06-16-2003, 03:09 PM
I want to have an image that when clicked displays a javascript prompt. How do I do that?

Thanks Tarq

pb&j
06-16-2003, 04:42 PM
something like this?

<a href="#" onclick="prompt('What is your name ?','');"><img src="imagename.gif" height="100" width="100" border="0" alt="test"></a>

tarq
06-16-2003, 04:51 PM
No sorry if I got the name wrong I need a window to put up like a little dialog box is that possible?

amicus
06-16-2003, 10:49 PM
try this one, i just took out one parameter from pb&j code. but which ever you want. if your not going to change the message for every image then just hard code it in if you want.


javascript:
<script language="javascript">
function prompt( message ) {
alert( message );
}
</script>

link:
<a href="#" onclick="prompt( 'What is your name?' );"><img src="imagename.gif" height="100" width="100" border="0" alt="test"></a>

tarq
06-17-2003, 01:52 PM
Yeah before I posted I edited the Javascript but guessed I must have been doing it wrong since it redirected me after I clicked OK. Why does it do that?

amicus
06-17-2003, 02:15 PM
you have to use the '#' sign otherwise you'll be redirected. the '#' will redirect the page back onto itself.