alexisbr
asked on
Trying to concatenate php and javascript
Hi. I have been trying to concatenate the following code for a pop up window using javascript but have not been successful. Does anyone have any ideas? I have worked around similar problems in other parts of this project by using include files and other tricks but, in this case, I really need the concatenated line because I am generating HTML code. I am getting the error "Parse error: syntax error, unexpected T_STRING....". I'm sure the problem is that there are single and double quotes already in the string so using a single or double quote for the concatenation is confusing php. But I don't know how to change it. I am using very similar javascript on another page and the popup window works fine. However, that page does not need to concatenate any values so I just used straight html outside of php tags.
Thanks for your help.
Alexis
Thanks for your help.
Alexis
$texttoadd3 = $texttoadd3.
'<div class="emailweb"><a href="http://www.xxxxx.com/new/contact.php?advertiserid=$id" onclick="window.open('http://www.xxxxx.com/new/contact.php?advertiserid=$id','popup','width=440,height=420,scrollbars=yes,resizable=yes,toolbar=no,directories=no,location=no,menubar=no,status=no,left=450,top=200'); return false">Email Us</a></div>';
Here's the straight html code that I used on another page and it worked perfectly.
<a style="color: #153E7E;text-decoration: none;" href="http://www.xxxxx.com/new/contact.php?advertiserid=<? echo $id;?>" onclick="window.open('http://www.xxxxx.com/new/contact.php?advertiserid=<? echo $id;?>','popup','width=440,height=420,scrollbars=yes,resizable=yes,toolbar=no,directories=no,location=no,menubar=no,status=no,left=450,top=200'); return false">Email Us</a>
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thanks again for your help.
Alexis
Open in new window