Jump to content

Javascript won't work when using header information!


Mutley

Recommended Posts

This makes no sense to me, I just can't understand it, so I'll try to explain for you to help me.

I'm using a javascript color picker. I have a file called form.php which has all the form options in and it has 2 fields where a color picker is used, when you click a link it opens a DIV box under the form displaying the selectable colours. If I have this code:

[b]EDIT: For some reason I can't post the code, I get a reconnection error.[/b]

In the file with no <html><header><body> tags it works fine.

When I add all the common file tags, like a header.php and footer.php the code doesn't work how it should. When I click the link the DIV box opens in the first form field and not under the 2nd when I click the 2nd.

I've tried putting the code everywhere and no luck, the only way to fix it is to not have the header.php in use (no html/header/body tags).

Any ideas?
Link to comment
Share on other sites

This is it:

[code]<S#CRIPT LANGUAGE="Javascript" SRC="ColorPicker2.js"></SCRIPT>
<S#CRIPT LANGUAGE="JavaScript">
var cp = new ColorPicker(); // DIV style
// Javascript for colour picker
</S#CRIPT>
[/code]

[code] <A HREF="#" onClick="cp.select(document.forms[0].font_content_color,'pick1');return false;" NAME="pick1" ID="pick1">Click here to pick a colour<br />
</A><s#cript language="JavaScript" type="text/javascript">cp.writeDiv()</script> </td>
[/code]

And it won't work no matter where I have it. Unless I don't include a header/footer.
Link to comment
Share on other sites

I've looked carefully at the source code, it isn't my HTML that is the problem. When I add the Script to the top of my header above the body/header/html tags it works but it cancels all my body/header/tags out because the javascript file is already producing them.

It skips my CSS file, but I can't see anywhere in the JS to show where it is producing these tags. I looked at the source when I included the file to see the code and it seems to think the "for" code tags in the JS file are the header/body/html tags, or along those lines.

The JS files source and example can be found here:
http://www.mattkruse.com/javascript/colorpicker/combined_source.html
Link to comment
Share on other sites

[quote author=Mutley link=topic=111138.msg451036#msg451036 date=1160675824]
I've looked carefully at the source code, it isn't my HTML that is the problem. When I add the Script to the top of my header above the body/header/html tags it works but it cancels all my body/header/tags out because the javascript file is already producing them.
[/quote]
I have no idea what you mean by "cancels".

[quote author=Mutley link=topic=111138.msg451036#msg451036 date=1160675824]
It skips my CSS file, but I can't see anywhere in the JS to show where it is producing these tags. I looked at the source when I included the file to see the code and it seems to think the "for" code tags in the JS file are the header/body/html tags, or along those lines.
[/quote]
Ditto.
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.