943,151 Members | Top Members by Rank

Ad:
Feb 8th, 2010
0

onClick event handler not executing in <input> tag

Expand Post »
Hello everyone,

I have a button on a page that is created with the <input> statement - this statement also contains the event handler onClick. The button displays correctly on the page but the event handler is not working - I know this as I put a simple alert at the beginning of the function PrcsBtn1. I am very new to all of this - what have I missed?

    <script type="text/javascript" language="javascript">
         function PrcsBtn1()
           {
             var data2 = new Array();
             data2[0] = "Cancel Appointment";

             var packedS="";
             for (i = 0; (i < data2.length); i++)
                {
                   if (i > 0)
                      {
                        packedS += ",";
                      }
                   packedS += escape(data2[i]);
                }

                window.location = "mypage11 new.html?"+packedS;
                window.open = "mypage11 new.html?"+packedS;
           }
    </script>

    <input name="b1" type="button" value="CANCEL APPOINTMENT" document.apptcalendar.b1.onClick="javascript:PrcsBtn1();">
Similar Threads
Reputation Points: 10
Solved Threads: 0
Newbie Poster
LoriM is offline Offline
8 posts
since Jan 2010
Feb 8th, 2010
0
Re: onClick event handler not executing in <input> tag
Get rid of the the extra stuff befor the event attribute. So it should look like this:

JavaScript / DHTML / AJAX Syntax (Toggle Plain Text)
  1. <input name="b1" type="button" value="CANCEL APPOINTMENT" document.apptcalendar.b1.onClick="javascript:PrcsBtn1();">

You also don't need the "javascript:"

So this is what it turns to:


JavaScript / DHTML / AJAX Syntax (Toggle Plain Text)
  1. <input name="b1" type="button" value="CANCEL APPOINTMENT" onClick="PrcsBtn1();">
Team Colleague
Reputation Points: 262
Solved Threads: 18
a.k.a inscissor
samaru is offline Offline
1,227 posts
since Feb 2002
Feb 8th, 2010
0
Re: onClick event handler not executing in <input> tag
Wow! Thanks loads...I think I'm finally catching on to this JavaScript stuff - not bad for an old mainframe programmer. Again, many, many thanks.
Reputation Points: 10
Solved Threads: 0
Newbie Poster
LoriM is offline Offline
8 posts
since Jan 2010

This thread is solved

Either the thread starter or a moderator has marked this thread as solved. You can most likely trust the responses and answers given. There is most likely no reason for any further responses to be posted here. If you have a related question, please start a new thread in this forum instead.

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in JavaScript / DHTML / AJAX Forum Timeline: I need your help Please!!!
Next Thread in JavaScript / DHTML / AJAX Forum Timeline: mouse over change content





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC