Jump to content


Photo

Javascript won't work when using header information!


  • Please log in to reply
8 replies to this topic

#1 Mutley

Mutley
  • Members
  • PipPipPip
  • Advanced Member
  • 765 posts

Posted 10 October 2006 - 09:54 PM

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:

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

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?
~ Mutley.

#2 fenway

fenway
  • Staff Alumni
  • MySQL Si-Fu / PHP Resident Alien
  • 16,199 posts
  • LocationToronto, ON

Posted 10 October 2006 - 10:13 PM

Obviously, you're producing invalid markup from these PHP files.
Seriously... if people don't start reading this before posting, I'm going to consider not answering at all.

#3 Mutley

Mutley
  • Members
  • PipPipPip
  • Advanced Member
  • 765 posts

Posted 10 October 2006 - 10:40 PM

Can you explain abit more? It isn't obvious to me - obviously. :P
~ Mutley.

#4 Mutley

Mutley
  • Members
  • PipPipPip
  • Advanced Member
  • 765 posts

Posted 11 October 2006 - 08:03 PM

Still getting problems, anyone?
~ Mutley.

#5 fenway

fenway
  • Staff Alumni
  • MySQL Si-Fu / PHP Resident Alien
  • 16,199 posts
  • LocationToronto, ON

Posted 11 October 2006 - 10:54 PM

I'd have to see the code... make sure you properly escape your script blocks when you post.
Seriously... if people don't start reading this before posting, I'm going to consider not answering at all.

#6 Mutley

Mutley
  • Members
  • PipPipPip
  • Advanced Member
  • 765 posts

Posted 12 October 2006 - 10:15 AM

This is it:

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

<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>

And it won't work no matter where I have it. Unless I don't include a header/footer.
~ Mutley.

#7 fenway

fenway
  • Staff Alumni
  • MySQL Si-Fu / PHP Resident Alien
  • 16,199 posts
  • LocationToronto, ON

Posted 12 October 2006 - 03:36 PM

Actually, I was looking for the final HTML output for the page that "doesn't work".
Seriously... if people don't start reading this before posting, I'm going to consider not answering at all.

#8 Mutley

Mutley
  • Members
  • PipPipPip
  • Advanced Member
  • 765 posts

Posted 12 October 2006 - 05:57 PM

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...ned_source.html
~ Mutley.

#9 fenway

fenway
  • Staff Alumni
  • MySQL Si-Fu / PHP Resident Alien
  • 16,199 posts
  • LocationToronto, ON

Posted 12 October 2006 - 06:30 PM

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.

I have no idea what you mean by "cancels".

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.

Ditto.
Seriously... if people don't start reading this before posting, I'm going to consider not answering at all.




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users