Jump to content

[SOLVED] Javascript and PHP


jimjx

Recommended Posts

Hi everyone,

 

I am trying to integrate a little bit of JS code into my PHP script.

 

Basically, this is for a calendar script and if someone clicks on a date, I want a new window to open with the info in it.

 

Right now I have this, and it does open a new window, but I need to be able to control the size and placement.

$ap1 = '<a href="'.$calendar_open_url."?Y=$cal_year&m=$cal_month&d=$day_num&$ox_tail".'" target="'.$calendar_open_target.'">'; $ap2 = '</a>';

 

I tried to use this but no go, and I (admittedly) don't know enough PHP to get this straightened out.

$ap1 = '<a href=\"\"onClick="window.open(\"'.$calendar_open_url.'?Y=$cal_year&m=$cal_month&d=$day_num&$ox_tail,'mywindow','width=400,height=200')'.'\" >'; $ap2 = '</a>';

 

Any suggestions on how I can accomplish this?

 

Thanks in advance,

Jim

 

Link to comment
https://forums.phpfreaks.com/topic/78779-solved-javascript-and-php/
Share on other sites

you were off on your quote balance and you concatenations

 

try this

 

<?php
$ap2 = "Open Window";
$ap1 = "<a href=\"javascript:void();\" onclick=\"window.open('".$calendar_open_url."?Y=".$cal_year."&m=".$cal_month."&d=".$day_num."&".$ox_tail."','mywindow','width=400,height=200')\">".$ap2."</a>";
echo $ap1;
?>

Wow!  Thank you for the very fast reply!

 

I think that is very close to what I need with one exception, it is putting 2 </a> in, here is the output...

<a href="javascript:void();" onclick="window.open('newCal.php?Y=2007&m=11&d=28&cal_id=0&language=english&gmt_ofs=0&view=d30','mywindow','width=400,height=200')"></a>28</td>

 

Here is the complete section of the code, I cannot see why the </a> is coming before the number.....

 

Jim

Never mind, I found the problem....

 

$ap1 = "<a href=\"javascript:void();\" onclick=\"window.open('".$calendar_open_url."?Y=".$cal_year."&m=".$cal_month."&d=".$day_num."&".$ox_tail."','mywindow','width=400,height=200')\">"[color=red].[/color] $ap2 . '</a>';

 

Should have been:

$ap1 = "<a href=\"javascript:void();\" onclick=\"window.open('".$calendar_open_url."?Y=".$cal_year."&m=".$cal_month."&d=".$day_num."&".$ox_tail."','mywindow','width=400,height=200')\">"[color=red];[/color] $ap2 . '</a>';

 

Thanks for all of the help, it works perfectly now.

 

Jim

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.