Jump to content

Embedding PHP in HTML "'". '. ". problems


notonurnelly

Recommended Posts

Hi all,

Just a quick question, Im sure it is very simple, I have a line of HTML code that calls a javascript function. The function basically scrolls layers. In order to scroll the javascript is sent a number of variable including in my case

A layer
and a value to scroll down to

the code below is a sample of the code which works.

onMouseOver="P7AniMagic('initial',0,-200,5,30,0,0)"

the two key values are the word initial and the -200.

the initial is the name of the layer I wish to scroll and -200 is by how much I wish to scroll.

for each of these I need to send values to in the form of variables so any layer can be scrolled any distance.

I can replace the -200 with the variable $ScrollVal

onMouseOver="P7AniMagic('initial',0,<?php echo $ScrollVal; ?>,5,30,0,0)"

this works fine, i then want to replace the layer name in the following way.

onMouseOver="P7AniMagic(<?php echo "'".$Layer2Scroll."'" ?>,0,<?php echo $ScrollVal; ?>,5,30,0,0)"

This does not work, Im sure I have some of the "'". the wrong way around.

Can anyone tell me how this should be wrote for characters, I seem to have managed the numbers by the $ScrollVal variable working okay.

The full code for that line is below

<div id="scroller" style="position:absolute; width:63px; height:23px; z-index:12; left: 774px; top: 275px; visibility: visible;"><img src="images/del.jpg" width="31" height="31" onMouseOver="P7AniMagic('initial',0,0,5,30,0,0)" onMouseOut="P7AniMagic('initial',0,0,1,1,2,0)"><img src="images/del.jpg" width="31" height="31" onMouseOver="P7AniMagic(<?php echo "'".$Layer2Scroll."'" ?>,0,<?php echo $ScrollVal; ?>,5,30,0,0)" onMouseOut="P7AniMagic('initial',0,0,1,1,2,0)">
</div>


Many Thanks
jamie


Link to comment
Share on other sites

Rather than going in and out of PHP mode. Use HEREDOC to echo out the HTML for the scroller:
[code=php:0]echo <<<SCROLLER
<div id="scroller" style="position:absolute; width:63px; height:23px; z-index:12; left: 774px; top: 275px; visibility: visible;">
  <img src="images/del.jpg" width="31" height="31" onMouseOver="P7AniMagic('initial',0,0,5,30,0,0)" onMouseOut="P7AniMagic('initial',0,0,1,1,2,0)">
  <img src="images/del.jpg" width="31" height="31" onMouseOver="P7AniMagic('{$Layer2Scroll}',0,{$ScrollVal},5,30,0,0)" onMouseOut="P7AniMagic('initial',0,0,1,1,2,0)">
</div>
SCROLLER;
// DO NOT INDENT OR PUT ANYTHING ON THE LINE ABOVE![/code]
Link to comment
Share on other sites

hi again wildteen

The page recgnised the echo, but again the layer did not scroll, its still the $layer2Scroll variable that is causing me problems, if I just replace the '{layer2scroll}'  with 'initial' its works fine.

So I still need to get the value of the variable to be read as text. What do you reckon.

Thanks
Again
Link to comment
Share on other sites

Hi Sasa

I cant tell, due to the fact that the function is in an external file, that is included. So when i view source i only get the info for that page i think.

onMouseOut="P7AniMagic('initial',0,0,1,1,2,0)">
  <img src="images/del.jpg" width="31" height="31" onMouseOver="P7AniMagic('',0,-2000,5,30,0,0)" onMouseOut="P7AniMagic('initial',0,0,1,1,2,0)">

altoguh i did find this code
Link to comment
Share on other sites

sasa

that worked okay,

thats when I set the variable within the code


<div id="scroller" style="position:absolute; width:63px; height:23px; z-index:12; left: 774px; top: 275px; visibility: visible;"><img src="images/del.jpg" width="31" height="31" onMouseOver="P7AniMagic('initial',0,0,5,30,0,0)" onMouseOut="P7AniMagic('initial',0,0,1,1,2,0)"><img src="images/del.jpg" width="31" height="31" onMouseOver="P7AniMagic(<?php $Layer2Scroll='initial'; echo "'".$Layer2Scroll."'" ?>,0,<?php echo $ScrollVal; ?>,5,30,0,0)" onMouseOut="P7AniMagic('initial',0,0,1,1,2,0)">
</div>

it also works when I do the below

$Layer2Scroll = "initial";

then

<div id="scroller" style="position:absolute; width:63px; height:23px; z-index:12; left: 774px; top: 275px; visibility: visible;"><img src="images/del.jpg" width="31" height="31" onMouseOver="P7AniMagic('initial',0,0,5,30,0,0)" onMouseOut="P7AniMagic('initial',0,0,1,1,2,0)"><img src="images/del.jpg" width="31" height="31" onMouseOver="P7AniMagic(<?php echo "'".$Layer2Scroll."'" ?>,0,<?php echo $ScrollVal; ?>,5,30,0,0)" onMouseOut="P7AniMagic('initial',0,0,1,1,2,0)">
</div>

but will not work when I send the variable $Layer2Scroll to the whole function as below

function scroller_set($upval,$Layer2Scroll)
{
echo "Layer ".$Layer2Scroll;
$ScrollVal = $upval * -2000;

echo $scrollval;



?>
<div id="scroller" style="position:absolute; width:63px; height:23px; z-index:12; left: 774px; top: 275px; visibility: visible;"><img src="images/del.jpg" width="31" height="31" onMouseOver="P7AniMagic('initial',0,0,5,30,0,0)" onMouseOut="P7AniMagic('initial',0,0,1,1,2,0)"><img src="images/del.jpg" width="31" height="31" onMouseOver="P7AniMagic(<?php echo "'".$Layer2Scroll."'" ?>,0,<?php echo $ScrollVal; ?>,5,30,0,0)" onMouseOut="P7AniMagic('initial',0,0,1,1,2,0)">
</div>
<?php
}


even though the echo statement

echo "Layer ".$Layer2Scroll;

is revealing

initial

I just dont get it, am I missing somethnig.

Thanks for your help i feel we are getting closer.

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.