Jump to content

[SOLVED] Java Script not working in PHP ???


Paldo

Recommended Posts

Hello everyone, I have this page with javascript working well, but now I need to put it into php and the script is not working... I never did this before so I have no idea how to solve it, please help... 

 

Working HTML page:

 

<html>
<head>
<title> ÄŽurkoviÄŤ </title>


<SCRIPT language="javascript1.1">
gifHome = new Image(54,18)
gifHome.src = "button_ofirme.png"
gifHome2 = new Image(54,18)
gifHome2.src = "button_ofirmeakt.png"
gifproduk = new Image(54,18)
gifproduk.src = "button_produktynakt.png"
gifproduk2 = new Image(54,18)
gifproduk2.src = "button_produkty.png"
gifsluz = new Image(54,18)
gifsluz.src = "button_sluzby.png"
gifsluz2 = new Image(54,18)
gifsluz2.src = "button_sluzbyakt.png"
gifref = new Image(54,18)
gifref.src = "button_referencie.png"
gifref2 = new Image(54,18)
gifref2.src = "button_referencieakt.png"
gifkon = new Image(54,18)
gifkon.src = "button_kontakt.png"
gifkon2 = new Image(54,18)
gifkon2.src = "button_kontaktakt.png"
gifdom = new Image(54,18)
gifdom.src = "button_domov.png"
gifdom2 = new Image(54,18)
gifdom2.src = "button_domovakt.png"


function changeImg(cImg,ref) {
document.images[cImg].src = ref.src
}
</SCRIPT>

</head>

<body>

<body bgcolor="black">


<div align="center" style='position:absolute;  left:0%; right:0%;  top:0%; height: 800px; width: 1280px; text-align: center; margin: 0 auto;   z-index: 0'> <img src='podklad.jpg' width="1280" height="800">   

<div style="position: absolute; left: 248px; top: 125px"> <img border="0" src="lista.png" > 

<div align="center" style="position: absolute;  left: 140px; top: 9px"> <a href="durky.html" onMouseOver="changeImg('imgofirme',gifHome2)"
onMouseOut="changeImg('imgofirme',gifHome)" > <img border="0" src="button_ofirme.png" name="imgofirme"    ></a> 

<div style="position: absolute; left: 90px; top: 0px"> <a href="produkty.html" onMouseOver="changeImg('imgprod',gifproduk2)" onMouseOut="changeImg('imgprod',gifproduk)" > <img border="0" src="button_produktynakt.png" name="imgprod"   > </a> 

<div style="position: absolute; left: 90px; top: 0px"> <a href="sluzby.html" onMouseOver="changeImg('imgsluz',gifsluz2)" onMouseOut="changeImg('imgsluz',gifsluz)" > <img border="0" src="button_sluzby.png" name="imgsluz"   > </a> 

<div style="position: absolute; left: 72px; top: 0px"> <a href="refer.html" onMouseOver="changeImg('imgref',gifref2)" onMouseOut="changeImg('imgref',gifref)"  > <img border="0" src="button_referencie.png" name="imgref"   > </a> 

<div style="position: absolute; left: 95px; top: 0px"> <a href="kontakt.html" onMouseOver="changeImg('imgkon',gifkon2)" onMouseOut="changeImg('imgkon',gifkon)"  > <img border="0" src="button_kontakt.png" name="imgkon"   > </a> 

<div style="position: absolute; left: 80px; top: 0px; text-align: left"> <a onMouseOver="changeImg('imgdom',gifdom2)" onMouseOut="changeImg('imgdom',gifdom)" href="durky.html" > <img border="0" src="button_domov.png" name="imgdom"    > </a> 

<div style= "position: absolute; left: -250pt; top: 85pt; width: 380pt">
<font  color="blue" size="2" face="Arial, Helvetica">
Regulačná stanica plynu je zariadenie pre automatickú reguláciu vstupného tlaku plynného média na nižší výstupný tlak. Ponúkame rôzne prevedenia regulačných staníc vzávislosti na výkone a vstupnom tlaku. Naše stanice dodávame v prevedení s jedným, alebo dvoma stupňami regulácie. Takisto môžu byť vybavené jednou alebo dvoma regulačnými radami. Výkon staníc je v rozmedzí od 150m3 do 10 000 m3, prípadne väčší. Regulačné stanice  sú obvykle dodávané ako stavba na kľúč, zmontované na ráme, alebo v skrini. 
</font>

<div style="position: absolute; left: -200px; top: 200px; text-align: left"> <a href="katarm.php" > <img border="0" src="button_katarma.JPG"    > </a> 

<div style= "position: absolute; left: 150pt; top: 30pt; width: 380pt">
<font color="blue" face="Arial, Helvetica">
Armaturky mame ale vacsinou ide o repas a ak si to aj kupite od nas tak vam to zacne haprovat po tyzdni pri najlepsom po dvoch... Je to proste brak. Ale tak co uz vam zostava ako si to kupit lebo vam to tu aj tak nikto iny ani nepreda. Vdaka panu bohu ze nie lebo by sme potom my nic nepredali...</font>

<div style="position: absolute; left: -200px; top: 100px; text-align: left"> <a href="katnahr.html" > <img border="0" src="button_katnahr.JPG"    > </a> 

<div style= "position: absolute; left: 150pt; top: 30pt; width: 380pt">
<font color="blue" face="Arial, Helvetica">
Mame aj nahradne diely ale predavame ich len v 50 kilogramovych vreciach s vystiznym nazvom MIX. Obsah tohto vreca je nahodny cize sa vam moze kludne stat ze si ich kupite par kym v dako najdete to co vam treba, ak vobec.</font>

</div>

</html>

 

But I want the next page to be a PHP so I tryed to do it like this:

 

<html>
<head>
<title> ÄŽurkoviÄŤ </title>

<style type="text/css">
a         {text-decoration: none}
a:link    {color: #c1c1c1; font-style: bold; background-image: url('button_blank.JPG') }
a:visited {color: #c1c1c1; font-style: bold; background-image: url('button_blank.JPG') }
a:active  {color: #c1c1c1; font-style: bold; background-image: url('button_blank.JPG') }
a:hover   {color: white; font-style: bold; text-decoration: none; background-image: url('button_aktiv.JPG') }
</style>

<SCRIPT language="javascript1.1">
gifHome = new Image(54,18)
gifHome.src = "button_ofirme.png"
gifHome2 = new Image(54,18)
gifHome2.src = "button_ofirmeakt.png"
gifproduk = new Image(54,18)
gifproduk.src = "button_produktynakt.png"
gifproduk2 = new Image(54,18)
gifproduk2.src = "button_produkty.png"
gifsluz = new Image(54,18)
gifsluz.src = "button_sluzby.png"
gifsluz2 = new Image(54,18)
gifsluz2.src = "button_sluzbyakt.png"
gifref = new Image(54,18)
gifref.src = "button_referencie.png"
gifref2 = new Image(54,18)
gifref2.src = "button_referencieakt.png"
gifkon = new Image(54,18)
gifkon.src = "button_kontakt.png"
gifkon2 = new Image(54,18)
gifkon2.src = "button_kontaktakt.png"
gifdom = new Image(54,18)
gifdom.src = "button_domov.png"
gifdom2 = new Image(54,18)
gifdom2.src = "button_domovakt.png"


function changeImg(cImg,ref) {
document.images[cImg].src = ref.src
}
</SCRIPT>

</head>

<body>

<?php

echo '<body bgcolor="black">';


echo'<div align="center" style="position:absolute;  left:0%; right:0%;  top:0%; height: 800px; width: 1280px; text-align: center; margin: 0 auto;   z-index: 0">'; 
echo'<img src="podklad.jpg" width="1280" height="800">';

echo'<div style="position: absolute; left: 248px; top: 125px">';
echo'<img border="0" src="lista.png" > ';

echo'<div align="center" style="position: absolute;  left: 140px; top: 9px">';
echo' <a href="durky.html" onMouseOver="changeImg(.imgofirme.,gifHome2)"
onMouseOut="changeImg(.imgofirme.,gifHome)" > <img border="0" src="button_ofirme.png" name="imgofirme"    ></a>';

echo'<div style="position: absolute; left: 90px; top: 0px">';
echo' <a href="produkty.html" onMouseOver="changeImg(.imgprod.,gifproduk2)" onMouseOut="changeImg(.imgprod.,gifproduk)" > <img border="0" src="button_produktynakt.png" name="imgprod"   > </a>';

echo'<div style="position: absolute; left: 90px; top: 0px">';
echo' <a href="sluzby.html" onMouseOver="changeImg(.imgsluz.,gifsluz2)" onMouseOut="changeImg(.imgsluz.,gifsluz)" > <img border="0" src="button_sluzby.png" name="imgsluz"   > </a> ';

echo'<div style="position: absolute; left: 72px; top: 0px">';
echo' <a href="refer.html" onMouseOver="changeImg(.imgref.,gifref2)" onMouseOut="changeImg(.imgref.,gifref)"  > <img border="0" src="button_referencie.png" name="imgref"   > </a> ';

echo'<div style="position: absolute; left: 95px; top: 0px">';
echo' <a href="kontakt.html" onMouseOver="changeImg(.imgkon.,gifkon2)" onMouseOut="changeImg(.imgkon.,gifkon)"  > <img border="0" src="button_kontakt.png" name="imgkon"   > </a> ';

echo'<div style="position: absolute; left: 80px; top: 0px; text-align: left">';
echo'<a onMouseOver="changeImg(.imgdom.,gifdom2)" onMouseOut="changeImg(.imgdom.,gifdom)" href="durky.html" > <img border="0" src="button_domov.png" name="imgdom"    > </a> ';



echo'</div>';

?>

</html>


 

Yet it is not working, so please help...

Link to comment
Share on other sites

Yeah I fixed that body stuff...

 

<html>
<head>
<title> ÄŽurkoviÄŤ </title>

<style type="text/css">
a         {text-decoration: none}
a:link    {color: #c1c1c1; font-style: bold; background-image: url('button_blank.JPG') }
a:visited {color: #c1c1c1; font-style: bold; background-image: url('button_blank.JPG') }
a:active  {color: #c1c1c1; font-style: bold; background-image: url('button_blank.JPG') }
a:hover   {color: white; font-style: bold; text-decoration: none; background-image: url('button_aktiv.JPG') }
</style>

<SCRIPT language="javascript1.1">
gifHome = new Image(54,18)
gifHome.src = "button_ofirme.png"
gifHome2 = new Image(54,18)
gifHome2.src = "button_ofirmeakt.png"
gifproduk = new Image(54,18)
gifproduk.src = "button_produktynakt.png"
gifproduk2 = new Image(54,18)
gifproduk2.src = "button_produkty.png"
gifsluz = new Image(54,18)
gifsluz.src = "button_sluzby.png"
gifsluz2 = new Image(54,18)
gifsluz2.src = "button_sluzbyakt.png"
gifref = new Image(54,18)
gifref.src = "button_referencie.png"
gifref2 = new Image(54,18)
gifref2.src = "button_referencieakt.png"
gifkon = new Image(54,18)
gifkon.src = "button_kontakt.png"
gifkon2 = new Image(54,18)
gifkon2.src = "button_kontaktakt.png"
gifdom = new Image(54,18)
gifdom.src = "button_domov.png"
gifdom2 = new Image(54,18)
gifdom2.src = "button_domovakt.png"


function changeImg(cImg,ref) {
document.images[cImg].src = ref.src
}
</SCRIPT>

</head>

<body>
<?php


echo '<body bgcolor="black">';


echo'<div align="center" style="position:absolute;  left:0%; right:0%;  top:0%; height: 800px; width: 1280px; text-align: center; margin: 0 auto;   z-index: 0">'; 
echo'<img src="podklad.jpg" width="1280" height="800">';

echo'<div style="position: absolute; left: 248px; top: 125px">';
echo'<img border="0" src="lista.png" > ';

echo'<div align="center" style="position: absolute;  left: 140px; top: 9px">';
echo' <a href="durky.html" onMouseOver="changeImg(.imgofirme.,gifHome2)"
onMouseOut="changeImg(.imgofirme.,gifHome)" > <img border="0" src="button_ofirme.png" name="imgofirme"    ></a>';

echo'<div style="position: absolute; left: 90px; top: 0px">';
echo' <a href="produkty.html" onMouseOver="changeImg(.imgprod.,gifproduk2)" onMouseOut="changeImg(.imgprod.,gifproduk)" > <img border="0" src="button_produktynakt.png" name="imgprod"   > </a>';

echo'<div style="position: absolute; left: 90px; top: 0px">';
echo' <a href="sluzby.html" onMouseOver="changeImg(.imgsluz.,gifsluz2)" onMouseOut="changeImg(.imgsluz.,gifsluz)" > <img border="0" src="button_sluzby.png" name="imgsluz"   > </a> ';

echo'<div style="position: absolute; left: 72px; top: 0px">';
echo' <a href="refer.html" onMouseOver="changeImg(.imgref.,gifref2)" onMouseOut="changeImg(.imgref.,gifref)"  > <img border="0" src="button_referencie.png" name="imgref"   > </a> ';

echo'<div style="position: absolute; left: 95px; top: 0px">';
echo' <a href="kontakt.html" onMouseOver="changeImg(.imgkon.,gifkon2)" onMouseOut="changeImg(.imgkon.,gifkon)"  > <img border="0" src="button_kontakt.png" name="imgkon"   > </a> ';

echo'<div style="position: absolute; left: 80px; top: 0px; text-align: left">';
echo'<a onMouseOver="changeImg(.imgdom.,gifdom2)" onMouseOut="changeImg(.imgdom.,gifdom)" href="durky.html" > <img border="0" src="button_domov.png" name="imgdom"    > </a> ';



echo'</div>';

?>

</body>



</html>

 

Now working I mean >>>  I use java script to change two images that are buttons and they change to look active/not active  when the mouse is on it. But they are not changeing in this php...  :(

 

There is a link to that page with working buttons and the upper of two beta buttons on the left is link to the non working php page...

 

http://www.parobek.euweb.cz/produkty.html

 

thanx

Link to comment
Share on other sites

You now have two <body> tags.

 

And anyway, why putting all JavaScript into PHP? It doesn't really make sense...

 

[added]

 

Something's wring with this

 

changeImg(.imgdom.,gifdom2)

 

should be

 

changeImg(\'imgdom\',gifdom2)

 

as far as I can see (and same stuff in other places)

Link to comment
Share on other sites

First of all thanks for your time and help so far...

 

Somehow it's not possible use \' stuff everytime I change it and save it it dissapears...  :confused:

 

When I reopen the file there are no \ in front of '

 

And I don't know if something is wrong with me but I realy cant find secon <body> tag

 

here is latest source... 

 

<html>
<head>
<title> ÄŽurkoviÄŤ </title>

<style type="text/css">
a         {text-decoration: none}
a:link    {color: #c1c1c1; font-style: bold; background-image: url('button_blank.JPG') }
a:visited {color: #c1c1c1; font-style: bold; background-image: url('button_blank.JPG') }
a:active  {color: #c1c1c1; font-style: bold; background-image: url('button_blank.JPG') }
a:hover   {color: white; font-style: bold; text-decoration: none; background-image: url('button_aktiv.JPG') }
</style>

<SCRIPT language="javascript1.1">
gifHome = new Image(54,18)
gifHome.src = "button_ofirme.png"
gifHome2 = new Image(54,18)
gifHome2.src = "button_ofirmeakt.png"
gifproduk = new Image(54,18)
gifproduk.src = "button_produktynakt.png"
gifproduk2 = new Image(54,18)
gifproduk2.src = "button_produkty.png"
gifsluz = new Image(54,18)
gifsluz.src = "button_sluzby.png"
gifsluz2 = new Image(54,18)
gifsluz2.src = "button_sluzbyakt.png"
gifref = new Image(54,18)
gifref.src = "button_referencie.png"
gifref2 = new Image(54,18)
gifref2.src = "button_referencieakt.png"
gifkon = new Image(54,18)
gifkon.src = "button_kontakt.png"
gifkon2 = new Image(54,18)
gifkon2.src = "button_kontaktakt.png"
gifdom = new Image(54,18)
gifdom.src = "button_domov.png"
gifdom2 = new Image(54,18)
gifdom2.src = "button_domovakt.png"


function changeImg(cImg,ref) {
document.images[cImg].src = ref.src
}
</SCRIPT>

</head>

<body>
<?php


echo '<body bgcolor="black">';


echo'<div align="center" style="position:absolute;  left:0%; right:0%;  top:0%; height: 800px; width: 1280px; text-align: center; margin: 0 auto;   z-index: 0">'; 
echo'<img src="podklad.jpg" width="1280" height="800">';

echo'<div style="position: absolute; left: 248px; top: 125px">';
echo'<img border="0" src="lista.png" > ';

echo'<div align="center" style="position: absolute;  left: 140px; top: 9px">';
echo' <a href="durky.html" onMouseOver="changeImg('imgofirme',gifHome2)"
onMouseOut="changeImg('imgofirme',gifHome)" > <img border="0" src="button_ofirme.png" name="imgofirme"    ></a>';

echo'<div style="position: absolute; left: 90px; top: 0px">';
echo' <a href="produkty.html" onMouseOver="changeImg('imgprod',gifproduk2)" onMouseOut="changeImg('imgprod',gifproduk)" > <img border="0" src="button_produktynakt.png" name="imgprod"   > </a>';

echo'<div style="position: absolute; left: 90px; top: 0px">';
echo' <a href="sluzby.html" onMouseOver="changeImg('imgsluz',gifsluz2)" onMouseOut="changeImg('imgsluz',gifsluz)" > <img border="0" src="button_sluzby.png" name="imgsluz"   > </a> ';

echo'<div style="position: absolute; left: 72px; top: 0px">';
echo' <a href="refer.html" onMouseOver="changeImg('imgref',gifref2)" onMouseOut="changeImg('imgref',gifref)"  > <img border="0" src="button_referencie.png" name="imgref"   > </a> ';

echo'<div style="position: absolute; left: 95px; top: 0px">';
echo' <a href="kontakt.html" onMouseOver="changeImg('imgkon',gifkon2)" onMouseOut="changeImg('imgkon',gifkon)"  > <img border="0" src="button_kontakt.png" name="imgkon"   > </a> ';

echo'<div style="position: absolute; left: 80px; top: 0px; text-align: left">';
echo'<a onMouseOver="changeImg('imgdom',gifdom2)" onMouseOut="changeImg('imgdom',gifdom)" href="durky.html" > <img border="0" src="button_domov.png" name="imgdom"    > </a> ';



echo'</div>';

?>

</body>



</html>

 

Any other ideas?  thanks

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.