Your function (checkfield) must return true if it wants the anchor acted on.


-----Original Message-----
From: Nathan Chen [mailto:[EMAIL PROTECTED]]
Sent: Friday, December 15, 2000 1:42 PM
To: CF-Talk
Subject: Re: Not Working in Netscape


Hi Jay,
I ran into a similar problem and I used your code below, but it does submit
the value in the <input > field but doesn't
fire the Javascript of onClick function.  I wonder if I did something wrong.
Here is my code:
============
<script language="Javascript">
function checkfield()
  {
      if  (document.forms[0].test.value =="")
      {
      alert ("You must enter a name.");
      document.forms[0].test.focus();
      return false;
      }
}
</script>

<html>
<head>
 <title>Untitled</title>
</head>

<body>

<form action="test.cfm" method="post">

<a onClick="return checkfield()">
<input type="image" src="graphics/workorder_red.gif">
</a>

<br><br>

Name:<input name="test" value="">

</form>

</body>
</html>
===========================

Nathan



Jay Brushett wrote:

> Hi,
>
> Netscape has a nasty way of not seeing onclick (and other) events in an
> image tag or image input element. Wrap anchors around it and place the
> onclick code inside.
>
> <a onclick="...."><input type=image ....></a>
>
> Jay
>
> At 06:39 PM 12/14/2000 +0800, you wrote:
> >Greeting,
> >Run the code below in IE, it will fire javascript before submit the form.
> >However, javascript is not running in Netscape. Unless the type="image"
> >change to type="submit".
> >
> >Anyone mind to tell me why?
> >
> >Thanks
> >- Rudy
> >
> >
> >
> >
> >
> ><cfparam name="name1" default="no name">
> >
> ><SCRIPT LANGUAGE="Javascript">
> ><!--
> >function checktime() {
> >   var thisday=new Date();
> >   var hour=thisday.getHours();
> >   if ((hour < 12) && (hour >=6))
> >     {alert ("Good Morning!");}
> >   if ((hour >= 12) && (hour < 18))
> >     {alert ("Good Afternoon!");}
> >   if ((hour >=18) && (hour < 22))
> >     {alert ("Good Evening! I hope you have had a good day");}
> >   if ((hour >=22) || (hour < 4))
> >     {alert ("It's late, you really ought to get to bed");}
> >   if ((hour >= 4) && (hour < 6))
> >     {alert ("It's early, you shouldn't be up yet");}
> >
> >
> >}
> >//-->
> ></SCRIPT>
> >
> >
> ><CFFORM action="test1.cfm" name="form1" method="post">
> >         <cfinput type="text" name="name1" value="abc"><br>
> >         <input type="Image" src="next.gif" onclick="checktime();">
> ></CFFORM>
> >
> >
> ><cfoutput>
> ><br>
> >         #name1#
> ><br>
> ></cfoutput>
> >
> >
>
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
        Structure your ColdFusion code with Fusebox. Get the official book at 
http://www.fusionauthority.com/bkinfo.cfm

Archives: http://www.mail-archive.com/cf-talk@houseoffusion.com/
Unsubscribe: http://www.houseoffusion.com/index.cfm?sidebar=lists

Reply via email to