Re: nesting JS in echo's
Request-1 wrote:
The heredoc is probably the best choice (as i'm not really a big fan
of dropping in and out of <?PHP ?for some reason, readability I
guess.) HEREDOC allows variable expansion...
Take a look at: http://us2.php.net/manual/en/language.types.string.php
--
Norman
Registered Linux user #461062
-Have you been to www.php.net yet?-
Request-1 wrote:
"Jerry Stuckle" <jstucklex@attg lobal.netwrote in message
news:gf2t4m$inr $1@registered.m otzarella.org.. .
>
>
>
Hi Jerry,
>
the single quote is actually necessary in JS when you're using
document.write to add strings in series (is it called "concatenat ing" or
something?). so the <img src...statement was broken down into 3 seperate
stings to be re-joined - all within the double-quote nested doc.write stmt.
my mistake was to leave the image path in single quotes; instead I tried
"escaped double quotes" to complete the image path, like so,
>
{ echo "<script language='JavaS cript1.2'>\n";
echo "<!-- begin \n";
echo "document.write ('<img src=\"images/swap/' + picnumber +'.jpg\"
width=\"320\" height=\"240\" border=\"0\" alt=\"Fitness Training
Image\">');\n";
echo "// end -->\n";
echo "</script>"; }
>
>
but no avail. still no pic shows up.
>
anyway. i get really confused with all the nested stuff and single-double
quotes. i may try that "heredoc" thing that Thomas suggested. I'll need a
couple of beers first. Friday night on Javascript? Bad!
>
>
news:gf2t4m$inr $1@registered.m otzarella.org.. .
>Request-1 wrote:
>You have an extra single quote before <img ...
>>hi folks,
>>>
>>html coder here, new and terrified * of php!!
>>aaaaaa!
>>>
>>i'm trying to bury a JS script to rotate a photo, in a page i converted
>>from html to php.
>>the conversion went well, it was to use a php session cookie to stop the
>>repeating of an embedded video file on a per session basis;
>>i amended the php code to display a still pic if the session cookie value
>>was nil.
>>>
>>worked fine.
>>>
>>thought I'd try integrating a tested and true JS image random rotator
>>script into the echo command, but the problem was the syntax of the
>>single quotes and double quotes needed in the doc.write and variable
>>sequences in the JS.
>>>
>>i tried escaping the double quotes (my echo used double quotes), but to
>>no avail.
>>>
>>here's the JS CODE i use in the tail end of my PHP. "picnumber" is the
>>variable holding the randomly assigned number that chooses the picture.
>>>
>>any help much appreciated..
>>>
>>>
>>+++++++++++++ +++
>>>
>>{ echo "
>>>
>> <script language='JavaS cript1.2'>
>> <!-- begin
>> document.write( \"'<img src='images/swap/'+ picnumber + '.jpg'>\");
>> // end -->
>></script>
>> "; }
>>>
>>+++++++++++++ +++++++++++++
>>>
>>thanks
>>>
>>html coder here, new and terrified * of php!!
>>aaaaaa!
>>>
>>i'm trying to bury a JS script to rotate a photo, in a page i converted
>>from html to php.
>>the conversion went well, it was to use a php session cookie to stop the
>>repeating of an embedded video file on a per session basis;
>>i amended the php code to display a still pic if the session cookie value
>>was nil.
>>>
>>worked fine.
>>>
>>thought I'd try integrating a tested and true JS image random rotator
>>script into the echo command, but the problem was the syntax of the
>>single quotes and double quotes needed in the doc.write and variable
>>sequences in the JS.
>>>
>>i tried escaping the double quotes (my echo used double quotes), but to
>>no avail.
>>>
>>here's the JS CODE i use in the tail end of my PHP. "picnumber" is the
>>variable holding the randomly assigned number that chooses the picture.
>>>
>>any help much appreciated..
>>>
>>>
>>+++++++++++++ +++
>>>
>>{ echo "
>>>
>> <script language='JavaS cript1.2'>
>> <!-- begin
>> document.write( \"'<img src='images/swap/'+ picnumber + '.jpg'>\");
>> // end -->
>></script>
>> "; }
>>>
>>+++++++++++++ +++++++++++++
>>>
>>thanks
>
>
Hi Jerry,
>
the single quote is actually necessary in JS when you're using
document.write to add strings in series (is it called "concatenat ing" or
something?). so the <img src...statement was broken down into 3 seperate
stings to be re-joined - all within the double-quote nested doc.write stmt.
my mistake was to leave the image path in single quotes; instead I tried
"escaped double quotes" to complete the image path, like so,
>
{ echo "<script language='JavaS cript1.2'>\n";
echo "<!-- begin \n";
echo "document.write ('<img src=\"images/swap/' + picnumber +'.jpg\"
width=\"320\" height=\"240\" border=\"0\" alt=\"Fitness Training
Image\">');\n";
echo "// end -->\n";
echo "</script>"; }
>
>
but no avail. still no pic shows up.
>
anyway. i get really confused with all the nested stuff and single-double
quotes. i may try that "heredoc" thing that Thomas suggested. I'll need a
couple of beers first. Friday night on Javascript? Bad!
>
>
of dropping in and out of <?PHP ?for some reason, readability I
guess.) HEREDOC allows variable expansion...
Take a look at: http://us2.php.net/manual/en/language.types.string.php
--
Norman
Registered Linux user #461062
-Have you been to www.php.net yet?-
Comment