Gossamer Forum
Home : Products : Links 2.0 : Customization :

javascript and Links

Quote Reply
javascript and Links
I have a javascript which I would like to use with links (on the add.html page). I am able to get the script working fine outside of links, but when I add it to add.html, I receive the following error:

Error: 'Type' is null or not an object
Code: 0
URL: http://domainname/cgi-bin/links/add.cgi

the javascript uses a .js file, url if you would like to download:
http://www.mattkruse.com/javascript/colorpicker/

I don't know enogh about javascripts to be able to edit them, but I am thinking that the problem may be with the href. I have included the code that I added to add.html below:

<head>
<title><%site_title%>: Add a Resource</title>
<link rel=stylesheet href="<%css%>" type="text/css" title="style sheet">
<SCRIPT LANGUAGE="Javascript" SRC="/javascript/ColorPicker2.js"></SCRIPT>
<SCRIPT LANGUAGE="JavaScript">
var cp = new ColorPicker('window'); // Popup window
var cp2 = new ColorPicker(); // DIV style
</SCRIPT>
</head>

<body>
<form>
<tr>
<td colspan="3"> <A HREF="#" onClick="cp.select(document.forms[0].header_font_colour,'pick');return false;" NAME="pick" ID="pick">Click
here to select colour</A>
<INPUT TYPE="text" NAME="header_font_colour" SIZE="20" VALUE=""> </td>
</tr>
<tr>
</form>

I have read that a few other members have had a similar problem to the one I have at the moment regarding javascript, but I have not been able to find the solution yet. I would be really greatful if someone could offer some help.

Thanks once again
Hamsterpants
Quote Reply
Re: [Hamsterpants] javascript and Links In reply to
After much hair pulling and head bashing, I found why the javascript wasn't working. I have an include statment which includes the header at the top of all pages. The heade file included a form tag (the search). When I comented this out, everything worked fine. Now the thing that gets me is if I add the include the statment below the javascript in the body, even without the search comented out it works fine????? Can anyone offer a reason why this would happen??

Hamsterpants
Quote Reply
Re: [Hamsterpants] javascript and Links In reply to
 
Quote Reply
Re: [Hamsterpants] javascript and Links In reply to
Create your form like this:

<form name="MyFormName">

Then change the onclick from:

onClick="cp.select(document.forms[0].header_font_colour,'pick');return false;" NAME="pick" ID="pick

to:

onClick="cp.select(document.forms.MyFornmName.header_font_colour,'pick');return false;" NAME="pick" ID="pick