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
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;
?>

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.