The Mother Board

Motherboards.org forums. Free tech support, motherboard ID, and more.
It is currently Tue Sep 25, 2018 3:48 pm

All times are UTC - 8 hours




Post new topic Reply to topic  [ 15 posts ]  Go to page 1, 2  Next
Author Message
PostPosted: Sat Mar 17, 2007 12:23 pm 
Offline
Lead Mobo-fu Master
Lead Mobo-fu Master

Joined: Sun Dec 16, 2001 1:01 am
Posts: 14301
Location: Maine
I am trying to get some code inserted to a page header file that when the $page_name == Support & Drivers a block of code gets included into the page otherwise it is not included. But all attempts have failed...

This is the code:
Code:
<script type="text/javascript">
<!-- Begin
function formHandler1(form1){
var URL = document.form1.site.options[document.form1.site.selectedIndex].value;
window.location.href = URL;
}
// End -->
</script>

<script type="text/javascript">
<!-- Begin
function formHandler2(form2){
var URL = document.form2.site.options[document.form2.site.selectedIndex].value;
window.location.href = URL;
}
// End -->
</script>


Thanks

_________________
Compaq-Fu Master
Ctechinfo funding drive information


Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: Sun Mar 18, 2007 4:17 am 
Offline
Green Belt
Green Belt

Joined: Thu Jun 27, 2002 8:11 pm
Posts: 222
Are you using SSI or something? I've had problems with javascript when I've had seperate javascript code in a header file and a body file. Maybe try to get it working in one html file then try splitting it up with SSI?

BTW where is the PHP if statement you refer to? Looks like javascript to me in that code example.


Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: Sun Mar 18, 2007 5:24 am 
Offline
Lead Mobo-fu Master
Lead Mobo-fu Master

Joined: Sun Dec 16, 2001 1:01 am
Posts: 14301
Location: Maine
Thanks olly. No SSI, or anything of that nature, just straight forward php/HTML/etc...

I was able to get it working (not at all what I was hoping for but it works). What I did was simply add another include to the page.

The problem (that I am fussing over now), is even though the javascript is now showing on the page and works, its not where I want it. I want it to show in the <head></head> tags not in the <body></body> tags. Currently dont have the page publically availible, but will try to get it uploaded soon...

As far as where the if statement is, I did not post that as I have gone through at least 5 attempts of trying different things out and only the extra include works....

Broken Code is:
Code:
<!doctype html public "-//W3C//DTD HTML 4.01//EN"
   "http://www.w3c.org/TR/html4/strict.dtd">
<html>
   <head>
      <title>Consumer Technical Information - Support & Drivers</title>
   <meta name="description" content="Your number one resource for Compaq & HP Support. With the largest database of Compaq/HP info availible anywhere." />
        <meta http-equiv="Content-Type" content="text/html; charset="iso-8859-1"/>
        <meta name="keywords" content="Compaq, Compaq PC's, compaq computers, Compaq technical support, computer hardware, compaq information, Compaq motherboards, Aspen, Aspen2, BMW/BMW-2, BMW-R, CAMARO, CE-31A, KBI-6130, KBA-6130, Mitac, FIC, Trigem, Asus, UIB1, ZZ-Top, MSI, MS-6553, Intel, BI440ZX, TR100, LORRETTO, Uwave, Uwave2, Uwave3, Uwave-R, AZ31, Pipeline, ELISE/ELISE-SWAP, Compaq Maintanence/Sevice Guides, motherboards, mainboards, mobos, HP, Presario, Pavilion, Deskpro, BRIO, Vectra, PC's, Maintainence/Service Guides, Manuals, BIOS files, drivers, motherboard identification" />
   <meta NAME="author" content="Toby Bibeau">
   <meta NAME="robots" content="all">
      <link rel="stylesheet" href="/common/compaq_style.css" type="text/css">
<?php if ($page_name == Support & Drivers) {
echo '<script type="text/javascript">
<!-- Begin
function formHandler1(form1){
var URL = document.form1.site.options[document.form1.site.selectedIndex].value;
window.location.href = URL;
}
// End -->
</script>

<script type="text/javascript">
<!-- Begin
function formHandler2(form2){
var URL = document.form2.site.options[document.form2.site.selectedIndex].value;
window.location.href = URL;
}
// End -->
</script>'};
?>
</head>

_________________
Compaq-Fu Master
Ctechinfo funding drive information


Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: Sun Mar 18, 2007 6:07 am 
Offline
Green Belt
Green Belt

Joined: Thu Jun 27, 2002 8:11 pm
Posts: 222
Hmm never seen php embedded in the <head> section before interesting. I see no reason why it shouldn't work though.

Have you tried putting everything in betweeen the echo single quotes ('') on one line? Its not very pretty to read but I've had to do this before to get something to work.

Could be that Support & Drivers has spaces and an & sign.

Maybe supportAndDrivers may be a better naming convention?

Also you may need to use escape characters for some of the javascript being printed.


Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: Sun Mar 18, 2007 4:46 pm 
Offline
Lead Mobo-fu Master
Lead Mobo-fu Master

Joined: Sun Dec 16, 2001 1:01 am
Posts: 14301
Location: Maine
olly wrote:
Hmm never seen php embedded in the <head> section before interesting. I see no reason why it shouldn't work though.

Have you tried putting everything in betweeen the echo single quotes ('') on one line? Its not very pretty to read but I've had to do this before to get something to work.

Could be that Support & Drivers has spaces and an & sign.

Maybe supportAndDrivers may be a better naming convention?

Also you may need to use escape characters for some of the javascript being printed.
I've tried encasing it in single quotes, double quotes, tried replacing echo with print (which sounds retarted as they do the same thing). As far as the seperated "support & drivers" I dont believe that would cause a problem, but then agian I am having a prolem somehere though... :o

_________________
Compaq-Fu Master
Ctechinfo funding drive information


Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: Mon Mar 19, 2007 11:19 am 
Offline
Green Belt
Green Belt

Joined: Thu Jun 27, 2002 8:11 pm
Posts: 222
What kind of an error are you getting Toby, is there gibberish text being displayed, or a blank page etc? Is $page_name being posted to this page?

IIRC I normally receive posted variables to a page like so:

$filename=$_POST["url"];


Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: Mon Mar 19, 2007 11:30 am 
Offline
Lead Mobo-fu Master
Lead Mobo-fu Master

Joined: Sun Dec 16, 2001 1:01 am
Posts: 14301
Location: Maine
Different parse errors are getting outputted but the remainder of the page does get outputted as normal...

Quote:
Is $page_name being posted to this page?
Yes and it works as it should...

_________________
Compaq-Fu Master
Ctechinfo funding drive information


Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: Mon Mar 19, 2007 11:41 am 
Offline
Green Belt
Green Belt

Joined: Thu Jun 27, 2002 8:11 pm
Posts: 222
Did you try using escape characters for the javascript being printed e.g:

echo '<script type=\"text


Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: Mon Mar 19, 2007 4:57 pm 
Offline
Lead Mobo-fu Master
Lead Mobo-fu Master

Joined: Sun Dec 16, 2001 1:01 am
Posts: 14301
Location: Maine
olly wrote:
Did you try using escape characters for the javascript being printed e.g:

echo '<script type="text
hmm no I had not thought of that. will try it whem I get home in the morning...

_________________
Compaq-Fu Master
Ctechinfo funding drive information


Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: Tue Mar 20, 2007 2:50 am 
Offline
Lead Mobo-fu Master
Lead Mobo-fu Master

Joined: Sun Dec 16, 2001 1:01 am
Posts: 14301
Location: Maine
olly wrote:
Did you try using escape characters for the javascript being printed e.g:

echo '<script type="text


Results:
Quote:
Parse error: parse error, unexpected '}', expecting ',' or ';' in D:\www1\ctechinfo\includes\header.inc on line 29

_________________
Compaq-Fu Master
Ctechinfo funding drive information


Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 15 posts ]  Go to page 1, 2  Next

All times are UTC - 8 hours


Who is online

Users browsing this forum: No registered users and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB® Forum Software © phpBB Group