"Robb Kerr" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
> Let me preface this by saying that I don't know JavaScript. I've got a
page
> that is built by a long complicated JavaScript that I was able to hack
just
> enough to function the way I wanted. There are some lines of code -- those
> that define div positioning -- that need to be different depending upon
> what it obtained from my database. I could build a simple PHP if/then
> statement and embed the entire JavaScript with the lines changed. Or, I
> could build a simple PHP if/then statement with only the lines of
> JavaScript that need to be changed and embed it within the JavaScript.
> which would be better?
>
> JavaScript in PHP
>
> <?php
> if (conditional) {
> ?>
> several lines of JavaScript
> <?php
> }
> ?>
>
>
> PHP in JavaScript
>
> <script language="JavaScript">
> several lines of JavaScript
> <?php
> if (conditional) {
> echo 'lines of JavaScript';
> } else {
> echo 'other lines of JavaScript';
> }
> ?>
> several lines of JavaScript
> </script>
>
>
> Thanx,
> Robb
Hi Rob,
maybe you can use the ternary operator syntax for the affected lines:
echo (conditional) ? 'lines of JavaScript'
: 'other lines of JavaScript';
Regards, Torsten Roehr
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php