Passing argurment preventing function from running

T

tshad

I have a ColorPicker program I found on the net that I am modifying to work
with mulitple objects on my page. I can't seem to get this to work if I
pass the object I want it to change. It works fine if I don't pass it
anything in this the picker.show() method.

I thought maybe it was because I was passing a asp:TextBox as an object.
But when I changed it to only use an "input" object I am having the same
problem.

I cut the program and .js file down to nothing to see what the problem and
found that it doesn't even get into the picker.show() method if I pass a
value. I have an "alert" as the only thing in the picker.show() function
and it will not execute if something is passed.

Here are the 2 files that work.
***********************************************************
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title>Untitled Document</title>
<script language="javascript" type="text/javascript"
src="testObject.js"></script>
<script language="javascript">
function pickerCallback(hexcolor) {
alert("In pickerCallback");
}
picker = new ColorPicker('picker', 'pickerCallback');
</script>
</head>
<body>
<form action="" method="get" name="form1">
<input name="color" type="text" disabled="true" size="8"
maxlength="7">&nbsp;
<a href="javascript:picker.show()"><img src="/images/icon.gif"
border="0"/></a>
</form>
</body>
</html>
******************************************************************

testObject.js
**************************************************
function ColorPicker(objName, callbackFunc) {
/**
* Properties
*/
this.objName = objName;
this.callbackFunc = callbackFunc;
this.show = ColorPicker_show;
}

function ColorPicker_show()
{
alert("Inside ColorPicker_show");
}
**********************************************************

Here are the 2 files that don't work. The only thing different is the
"ColorPicker_show(me)" in the .js file and the
href="javascript:picker.show(color)" in the link.

****************************************************************
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title>Untitled Document</title>
<script language="javascript" type="text/javascript"
src="testObject.js"></script>
<script language="javascript">
function pickerCallback(hexcolor) {
alert("In pickerCallback");
}
picker = new ColorPicker('picker', 'pickerCallback');
</script>
</head>
<body>
<form action="" method="get" name="form1">
<input name="color" type="text" disabled="true" size="8"
maxlength="7">&nbsp;
<a href="javascript:picker.show(color)"><img src="/images/icon.gif"
border="0"/></a>
</form>
</body>
</html>
****************************************************************

testObject.js
****************************************************************
function ColorPicker(objName, callbackFunc) {
/**
* Properties
*/
this.objName = objName;
this.callbackFunc = callbackFunc;
this.show = ColorPicker_show;
}

function ColorPicker_show(me)
{
alert("Inside ColorPicker_show");
}
****************************************************************

Am I not calling the function correctly?

Thanks,

Tom
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
474,158
Messages
2,570,882
Members
47,414
Latest member
djangoframe

Latest Threads

Top