Jump to content


Photo

popup new window


  • Please log in to reply
4 replies to this topic

#1 cikzann

cikzann
  • New Members
  • Pip
  • Newbie
  • 2 posts

Posted 24 July 2006 - 02:42 AM

i would like to know if anyone can help me how to popup window using javascript and php..the php script will call the javascript function to popup new window, but, it needs to pass the parameter that read from mySQL db...

actually i need to build a calendar with events. when we click to the day that have the events, a popup will appear and the data is read from the database

thank u

#2 bltesar

bltesar
  • Members
  • PipPipPip
  • Advanced Member
  • 109 posts

Posted 28 July 2006 - 02:12 PM

There are a couple of ways that I know to do this. 

I assume that the liks from your calendar will all open the same window that is dynamically generated based on the user selection. 

Your links could look like this:

<a href="javascript:get_data('thischoice');>text identifying this choice</a>

and the function looks like this:
var openedWindow;
get_data(user_selection){

//user_selection is sent via GET to process dynamic PHP page
newURL='show_data.php?user_selection='+user_selection;
if(openedWindow!=null)
{
     openedWindow.location.href=newURL;
}
else
{
     openedWindow=window.open(newURL, "", "height=400, width=500, resizable=false, etc.");
}
}
the same can be done using the POST method.  set newURL as the form's action and openedWindow as the target.  The function then looks like this:
var openedWindow;
get_data(user_selection){

//user_selection is sent via POST to process dynamic PHP page
window.forms[0].user_selection.value='+user_selection;

if(openedWindow=null)
{
     openedWindow=window.open("", "", "height=400, width=500, resizable=false, etc.");
}

window.forms[0].submit();
}


#3 bltesar

bltesar
  • Members
  • PipPipPip
  • Advanced Member
  • 109 posts

Posted 28 July 2006 - 02:16 PM


Sorry, there were some mistakes in the last block of code, the function to be used for POST submits:


var openedWindow;
get_data(user_selection){

//user_selection is sent via POST to process dynamic PHP page
window.forms[0].user_selection.value=user_selection;

if(openedWindow==null)
{
     openedWindow=window.open("", "", "height=400, width=500, resizable=false, etc.");
}

window.forms[0].submit();
}


set show_data.php as the form's action

#4 cikzann

cikzann
  • New Members
  • Pip
  • Newbie
  • 2 posts

Posted 31 July 2006 - 02:58 AM

thanks a lot....

but now, i still have problem with the calendar....

the popup problem have been settled...but another problem arise...

the date which is the same date for other month which have events doesn't print out in the calendar...

the code is like below

$i = 0; 
foreach($weeks as $week){
echo "<tr>\n"; 
foreach($week as $d){ 
 							                           	 
   if(($i >= $offset_count) && ($i < ($num_weeks * 7) - $outset)){ 
                           								
       $date = "$year-$month-$d";
             if (in_array($d,$dateArray)) {
							   
             for ($f =0; $f < $num3; $f++)
										
            {				 
	    $date_in_db = mysql_result($Result3,$f,"blogDate");
    	      if ($date == $date_in _db)
												     { 						   					        echo "<td class=\"linkedDay\" align=\"center\" >
                             <a target=\"popup\" onclick=\"var aWin=window.open
                               ('','popup','width=200,height=200,top=350,left=400,resizeable=no,scrollbars=no');
		      aWin.focus();\"href=\"blog2.php?date=$date\">$d</a></td>\n";			     }
            }
											 
} else if($date == date("Y-m-d")){
   echo "<td class=\"today\" align=\"center\" >$d</td>\n";
 } else { 
   echo "<td class=\"days\" align=\"center\" >$d</td>\n"; 
} 
									
The date in the db...
11/07/2006 - events
25/07/2006 - events
30/08/2006 - events



#5 bltesar

bltesar
  • Members
  • PipPipPip
  • Advanced Member
  • 109 posts

Posted 02 August 2006 - 03:48 PM

It looks like you have omitted a lot of the actual code here.  There is not enough information for me to make sense of it.  A lot of the variables are not explained and the logical structure is incomplete.

Post the entire code or at least more and maybe I can help.




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users