Jump to content

Archived

This topic is now archived and is closed to further replies.

Mutley

Javascript won't work when using header information!

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?

Share this post


Link to post
Share on other sites
Obviously, you're producing invalid markup from these PHP files.

Share this post


Link to post
Share on other sites
I'd have to see the code... make sure you properly escape your script blocks when you post.

Share this post


Link to post
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.

Share this post


Link to post
Share on other sites
Actually, I was looking for the final HTML output for the page that "doesn't work".

Share this post


Link to post
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

Share this post


Link to post
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.

Share this post


Link to post
Share on other sites

×

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.