RE: [PHP] setting var inside JS

From: Date: Wed, 07 Aug 2002 19:07:12 +0000
Subject: RE: [PHP] setting var inside JS
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-111565@lists.php.net to get a copy of this message
Ok, I see what you've done, you just escaped differently then I did, but your right that is cleaner. I ended up using "here document" syntax. I don't think you can get more readable then that... :) echo <<<ENDJS <td> <a href="#" onclick="popup('./?id=$row->id&nw=1','ig','width=640,height=455,toolbar=no,s crollbars=yes,resizable=yes,location=no');"> <img src="/ss/thumbnails/$img" $size[3] alt="click to enlarge" /></a> </td> ENDJS; And, I found the JS error and it's more stupid then I care to admit.. :) -Brian > -----Original Message----- > From: Andrew Brampton [mailto:andrew@bramp.freeserve.co.uk] > Sent: Wednesday, August 07, 2002 2:46 PM > To: php-general@lists.php.net > Subject: Re: [PHP] setting var inside JS > > > That might be a problem of your JS.. > But just to make sure the correct line should be: > echo '<a href="#" onclick="' . "popup('./?id=" . > $row->id . > "&nw=1','ig','width=640,height=455,toolbar=no,scrollbars=yes,resiz > able=yes,l > ocation=no')" . ';">'; > > Hope this helps > Andrew > ----- Original Message ----- > From: "Brian V Bonini" <b-bonini@cox.net> > To: "Andrew Brampton" <andrew@bramp.freeserve.co.uk>; "PHP Lists" > <php-general@lists.php.net> > Sent: Wednesday, August 07, 2002 7:40 PM > Subject: RE: [PHP] setting var inside JS > > > > Hmm, thanks, I think. I was not really looking for an analysis of my > syntax > > but ok... I'm always up for an additional tip.. :) > > > > Personally, I'm not really sure how else you would write it but the code > > produces exactly what it should so I'm not sure why your telling me it > "wont > > work": > > > > <a href="#" > > > > onclick="popup('./?id=2&nw=1','ig','width=640,height=455,toolbar=n > o,scrollba > > rs=yes,resizable=yes,location=no');"><img > > src="/ss/thumbnails/2.jpg"width="48" > > height="75"alt="click to enlarge" > > /></a></td><td> > > > > The problem is "nw" does not seem to be getting passed to php > the same way > > it would if the above were written: > > > > <a href="./?id=2&nw=1" etc... > > > > So, my question stands.... > > > > Thanks, > > -B > > ************* > > > > > -----Original Message----- > > > From: Andrew Brampton [mailto:andrew@bramp.freeserve.co.uk] > > > Sent: Wednesday, August 07, 2002 2:24 PM > > > To: Brian V Bonini; PHP Lists > > > Subject: Re: [PHP] setting var inside JS > > > > > > > > > nw seems to be set to 1 there, but it seems to me that your > line is VERY > > > messy due to all the ' and " try breaking it down a bit then you > > > might have > > > more luck with all the quotes, ie > > > > > > echo '<td>'; > > > echo '<a href="#" onclick="popup(\'./?id=' . > > > $row->id . > > > > > > '&nw=1\',\'ig\',\'width=640,height=455,toolbar=no,scrollbars=yes,r > > > esizable=y > > > es,location=no\');">'; > > > echo '<img src="/ss/thumbnails/' . $img . '"' . > > > $size[3] . 'alt="click > to > > > enlarge" /></a></td>'; > > > > > > The middle line wont work, due to the overuse of ' and \' (which > > > won't work > > > inside the ' quotes)... > > > Anyway this is just a start, take you a few minutes to sort out the > middle > > > line.. > > > If you have trouble, write down what it should look like in > the browser, > > > then work back from that... > > > > > > Andrew > > > ----- Original Message ----- > > > From: "Brian V Bonini" <b-bonini@cox.net> > > > To: "PHP Lists" <php-general@lists.php.net> > > > Sent: Wednesday, August 07, 2002 7:17 PM > > > Subject: [PHP] setting var inside JS > > > > > > > > > > Is it possible to set a var in side a JS statement? I can not > > > seem to set > > > > "nw" in the following statement. > > > > > > > > echo '<td><a href="#" > > > > onclick="popup(\'./?id=' . $row->id . > > > > > > > > > > '&nw=1\',\'ig\',\'width=640,height=455,toolbar=no,scrollbars=yes,r > > > esizable=y > > > > es,location=no\');"><img src="/ss/thumbnails/' . $img > > > > . '"' > . $size[3] > . > > > > 'alt="click to enlarge" /></a></td>'; > > > > > > > > > > > > -- > > > > PHP General Mailing List (http://www.php.net/) > > > > To unsubscribe, visit: http://www.php.net/unsub.phpÔWåî[æ,„;Ù > > > > x¼ÃI > > > > > > > > > > > > > > > > > -- > > > PHP General Mailing List (http://www.php.net/) > > > To unsubscribe, visit: http://www.php.net/unsub.php > > > > > > > > > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php >

« previous php.general (#111565) next »