954,174 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

onClick event handler not executing in <input> tag

Hello everyone,

I have a button on a page that is created with the 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();">

LoriM
Newbie Poster
8 posts since Jan 2010
Reputation Points: 10
Solved Threads: 0
 

Get rid of the the extra stuff befor the event attribute. So it should look like this:

<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:

<input name="b1" type="button" value="CANCEL APPOINTMENT" onClick="PrcsBtn1();">
samaru
a.k.a inscissor
Team Colleague
1,256 posts since Feb 2002
Reputation Points: 262
Solved Threads: 18
 

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.

LoriM
Newbie Poster
8 posts since Jan 2010
Reputation Points: 10
Solved Threads: 0
 

This question has already been solved

Post: Markdown Syntax: Formatting Help
You