Board Logo

Newbie Needs Help Calling Color Picker
MartyL - 3/17/2011 at 04:07 PM

I'm writing a context menu extension for Safari but I'm new to Javascript and so at this point I'm a little over me head.

You may be aware of this but an extension consists of a global HTML page and one or more Javascripts. The HTML dispatches messages to the Javascripts and the scripts listen for those dispatches via event listeners. I'd like to display and use the selection from Color Picker to color the user-selected text in the TEXTAREA of a web page.

What I've done so far is this:

In my HTML I have

<link rel=stylesheet href="color_select.css" type="text/css"/>
<script type="text/javascript" src="color_select.js"></script>
<form name='frmSelectColor' >
<!-- some inner HTML of the form -->
<!-- Add input box to the form -->
<input type="Text" name="theColor">
<!-- Color Picker initialization and anchor icon to call a picker -->
<a href="javascript:TCP.popup(document.forms['frmSelectColor'].elements['theColor'])">
<img width="15" height="13" border="0" alt="Click Here to Pick up the color" src="img/sel.gif"></a>

and in my Javascript I have

TCP.popup(document.forms['frmSelectColor'].userSelText, 0);

When the code executes I get a 'TypeError: Result of expression 'document.forms['frmSelectColor']' [undefined] is not an object' error and I don't know how to fix it.

Back to forum: