notonurnelly Posted September 14, 2006 Share Posted September 14, 2006 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 tothe 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 $ScrollValonMouseOver="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 Thanksjamie Quote Link to comment https://forums.phpfreaks.com/topic/20741-embedding-php-in-html-problems/ Share on other sites More sharing options...
wildteen88 Posted September 14, 2006 Share Posted September 14, 2006 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] Quote Link to comment https://forums.phpfreaks.com/topic/20741-embedding-php-in-html-problems/#findComment-91805 Share on other sites More sharing options...
notonurnelly Posted September 14, 2006 Author Share Posted September 14, 2006 hi many thanks for your reply, I have never used that technique before. Wil lthis solve the problem I am having trying to get. Layer variable to be read as its value?Many ThanksJamie Quote Link to comment https://forums.phpfreaks.com/topic/20741-embedding-php-in-html-problems/#findComment-91890 Share on other sites More sharing options...
wildteen88 Posted September 14, 2006 Share Posted September 14, 2006 Not sure but try the code out first and see if it works. However It should do. All I've done is taken your code and put it into a big echo statement. Quote Link to comment https://forums.phpfreaks.com/topic/20741-embedding-php-in-html-problems/#findComment-91900 Share on other sites More sharing options...
notonurnelly Posted September 14, 2006 Author Share Posted September 14, 2006 hi again wildteenThe 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.ThanksAgain Quote Link to comment https://forums.phpfreaks.com/topic/20741-embedding-php-in-html-problems/#findComment-91919 Share on other sites More sharing options...
sasa Posted September 14, 2006 Share Posted September 14, 2006 look page source in your browseris it look OK? Quote Link to comment https://forums.phpfreaks.com/topic/20741-embedding-php-in-html-problems/#findComment-91951 Share on other sites More sharing options...
notonurnelly Posted September 14, 2006 Author Share Posted September 14, 2006 Hi SasaI 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 Quote Link to comment https://forums.phpfreaks.com/topic/20741-embedding-php-in-html-problems/#findComment-91967 Share on other sites More sharing options...
sasa Posted September 14, 2006 Share Posted September 14, 2006 is it variable $Layer2Scroll set uptry change [code]<?php echo "'".$Layer2Scroll."'" ?>[/code]to[code]<?php $Layer2Scroll='initial'; echo "'".$Layer2Scroll."'" ?>[/code]if it works, check twice thet yuor variable have good value Quote Link to comment https://forums.phpfreaks.com/topic/20741-embedding-php-in-html-problems/#findComment-91978 Share on other sites More sharing options...
notonurnelly Posted September 14, 2006 Author Share Posted September 14, 2006 sasathat 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 belowfunction 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 statementecho "Layer ".$Layer2Scroll;is revealinginitialI just dont get it, am I missing somethnig.Thanks for your help i feel we are getting closer. Quote Link to comment https://forums.phpfreaks.com/topic/20741-embedding-php-in-html-problems/#findComment-91986 Share on other sites More sharing options...
notonurnelly Posted September 14, 2006 Author Share Posted September 14, 2006 I have just checked my variable type using the code below$varTyi = gettype($Layer2Scroll);echo $varTyi; and it is a string. Quote Link to comment https://forums.phpfreaks.com/topic/20741-embedding-php-in-html-problems/#findComment-92028 Share on other sites More sharing options...
notonurnelly Posted September 15, 2006 Author Share Posted September 15, 2006 Im still struggling with this, does anyone have any fresh ideas? Quote Link to comment https://forums.phpfreaks.com/topic/20741-embedding-php-in-html-problems/#findComment-92261 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.