Re: [PHP] Works in html, not when echoed in PHP
"Aaron Merrick" <[EMAIL PROTECTED]> wrote: > You are right, there is a reason I am echoing it in php, it is one result of > an if statement. Well, I thought so :) ...[snip]... > I tried echoing with single quotes - no change. So I compared the view > source of the double quoted php generated page and of the html generated > page - they are identical: > > onresize="window.location.reload(false)" topmargin="1" bottommargin="0" > leftmargin="0" rightmargin="0"> > > So I no longer think php is parsing the javascript incorrectly - the same > error happens if I put the 'onoff()' function directly in html and only put > the 'start()' function in the if statement. The weird thing is that the php > page still gives the error and the html does not. I can only guess... What happens when you take out the start() then? I think it'd be a good idea anyway to take away the js codes in your tag (also the xxxmargin stuffs) since your page wouldn't actually validate as valid xhtml (if you're concerned of course...). Is it not possible to put those inside the tags, in-between
Re: [PHP] Works in html, not when echoed in PHP
I'm not constructing it with, it is just included in the file. Does that clarify? Or did I misunderstand your point? On 11/13/02 1:47 AM, "Ernest E Vogelsinger" <[EMAIL PROTECTED]> wrote: > You didn't show how you construct the JavaScript string in PHP - I'm sure > the problem is with quoting in there. > > Have a look at your output in the browser (do a "View Source" or whatever > your Browser calls it), and check the JS your PHP application constructed. > You'll spot the error... > > At 05:28 13.11.2002, Aaron Merrick said: > [snip] >> Folks, >> >> Can't see an answer anywhere in the archives, so here goes. >> >> This works fine in plain html: >> >> > onresize="window.location.reload(false)" topmargin="1" bottommargin="0" >> leftmargin="0" rightmargin="0"> >> >> When I put it in PHP thus: >> >> echo "> onresize=\"window.location.reload(false)\" topmargin=\"1\" >> bottommargin=\"0\" leftmargin=\"0\" rightmargin=\"0\">"; >> >> When the page loads, I get an "Error: 'menuObj' is null or not an object" >> >> The onoff() function is what contains the menuObj, so I suspect the single >> quotes around the parameters mainmenu and on, but have tried everyway I can >> think of and can't get rid of the Error. >> >> The function is thus: >> >> function onoff (elemparent,elem,state) { >> if (loaded) { >> newstate = eval(elem+"_"+state); >> if (n4) { >> menuObj = eval (doc + elemparent + doc2 + elem); >> } >> else if (ie || n6) { >> menuObj = eval (doc + elem + doc2); >> } >> >> I would be grateful for any tips. >> >> Thanks, >> Aaron >> >> >> -- >> PHP General Mailing List (http://www.php.net/) >> To unsubscribe, visit: http://www.php.net/unsub.php > [snip] -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Works in html, not when echoed in PHP
You are right, there is a reason I am echoing it in php, it is one result of an if statement. "; } else { echo ""; } ?> I tried echoing with single quotes - no change. So I compared the view source of the double quoted php generated page and of the html generated page - they are identical: So I no longer think php is parsing the javascript incorrectly - the same error happens if I put the 'onoff()' function directly in html and only put the 'start()' function in the if statement. The weird thing is that the php page still gives the error and the html does not. Anyway, I thought I would see if there were any more ideas as to what I am doing wrong. Thanks for the help, Aaron On 11/13/02 12:50 AM, "@ Edwin" <[EMAIL PROTECTED]> wrote: > echo ' onresize="window.location.reload(false)" topmargin="1" bottommargin="0" > leftmargin="0" rightmargin="0">'; -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Works in html, not when echoed in PHP
You didn't show how you construct the JavaScript string in PHP - I'm sure the problem is with quoting in there. Have a look at your output in the browser (do a "View Source" or whatever your Browser calls it), and check the JS your PHP application constructed. You'll spot the error... At 05:28 13.11.2002, Aaron Merrick said: [snip] >Folks, > >Can't see an answer anywhere in the archives, so here goes. > >This works fine in plain html: > >onresize="window.location.reload(false)" topmargin="1" bottommargin="0" >leftmargin="0" rightmargin="0"> > >When I put it in PHP thus: > >echo "onresize=\"window.location.reload(false)\" topmargin=\"1\" >bottommargin=\"0\" leftmargin=\"0\" rightmargin=\"0\">"; > >When the page loads, I get an "Error: 'menuObj' is null or not an object" > >The onoff() function is what contains the menuObj, so I suspect the single >quotes around the parameters mainmenu and on, but have tried everyway I can >think of and can't get rid of the Error. > >The function is thus: > >function onoff (elemparent,elem,state) { >if (loaded) { >newstate = eval(elem+"_"+state); >if (n4) { >menuObj = eval (doc + elemparent + doc2 + elem); > } >else if (ie || n6) { >menuObj = eval (doc + elem + doc2); > } > >I would be grateful for any tips. > >Thanks, >Aaron > > >-- >PHP General Mailing List (http://www.php.net/) >To unsubscribe, visit: http://www.php.net/unsub.php [snip] -- >O Ernest E. Vogelsinger (\)ICQ #13394035 ^ http://www.vogelsinger.at/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Works in html, not when echoed in PHP
"Chris Shiflett" <[EMAIL PROTECTED]> wrote: ...[snip]... > Yes, this is the same code that "works fine in plain html". Why echo it in PHP if it is static? Good question ;) But I'm sure there's a good a answer :) Besides, why would anybody want to do that if there's no good reason? - E -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Works in html, not when echoed in PHP
@ Edwin wrote: "Aaron Merrick" <[EMAIL PROTECTED]> wrote: This works fine in plain html: When I put it in PHP thus: echo ""; When the page loads, I get an "Error: 'menuObj' is null or not an object" I think php is parsing your js code. Have you tried echoing with single quotes? echo ''; Or better yet, try this: Yes, this is the same code that "works fine in plain html". Why echo it in PHP if it is static? Chris -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Works in html, not when echoed in PHP
Hello, "Aaron Merrick" <[EMAIL PROTECTED]> wrote: > Folks, > > Can't see an answer anywhere in the archives, so here goes. > > This works fine in plain html: > > onresize="window.location.reload(false)" topmargin="1" bottommargin="0" > leftmargin="0" rightmargin="0"> > > When I put it in PHP thus: > > echo " onresize=\"window.location.reload(false)\" topmargin=\"1\" > bottommargin=\"0\" leftmargin=\"0\" rightmargin=\"0\">"; > > When the page loads, I get an "Error: 'menuObj' is null or not an object" > > The onoff() function is what contains the menuObj, so I suspect the single > quotes around the parameters mainmenu and on, but have tried everyway I can > think of and can't get rid of the Error. > > The function is thus: > I think php is parsing your js code. Have you tried echoing with single quotes? echo ''; - E -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php