Solved

opening a javascript link in php -again

Posted on 2006-11-12
7
261 Views
Last Modified: 2008-03-04
Thanks for solving my other post. I managed to solve all the other one except this one


echo ('<a  href="#"
onclick="window.open(\'news/old_news_list.php?month=$j&amp;year='.$i.'\',\'\',\'width=700,height=500\');
return false \" >$thisMonth</a>');


This doesn't open, but again I cannot see where I have gone wrong. Everything looks escaped and sorted. Thanks,


Ross
0
Comment
Question by:roscoeh23
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
7 Comments
 
LVL 143

Expert Comment

by:Guy Hengel [angelIII / a3]
ID: 17924723
the problem is that the variables $j, $i, and $thisMonth do not get replaced by their values, because you used ' for the string.
the following might work better:

echo ("<a  href=\"#\"
onclick=\"window.open(\'news/old_news_list.php?month=$j&amp;year='.$i.'\',\'\',\'width=700,height=500\\\');
return false \" >$thisMonth</a>");
0
 
LVL 49

Expert Comment

by:Roonaan
ID: 17924730
What about using something like this:


$winopen = "window.open('news/old_news_list.php?month=$j&amp;year=$i','',''width=700,height=500);return false;"
echo '<a href=""#" onclick="'.$winOpen.'">'.$thisMonth.'</a>';

Because you where using single quotes, you must notice that your $j, $i and $thisMonth will not be replaced automatically.This will  only happen when using double quotes.

-r-
0
 

Author Comment

by:roscoeh23
ID: 17924769
I noticed the mistake $winOpen and $winopen. That looked like it was going to work bur neither do the job.


They both do not open the javascript window which suggests a stntax error or the variable is not getting passed in Roonaan's example.



thanks,


Ross





0
Salesforce Has Never Been Easier

Improve and reinforce salesforce training & adoption using WalkMe's digital adoption platform. Start saving on costly employee training by creating fast intuitive Walk-Thrus for Salesforce. Claim your Free Account Now

 
LVL 49

Expert Comment

by:Roonaan
ID: 17924777
Can you do view source from your browser and show us a relevant snippet?

-r-
0
 

Author Comment

by:roscoeh23
ID: 17924784
this is with your version of the code

      // Output required months
      for ($j = $monMax; $j >= $monMin; $j--) {
            // Disp month
            $thisMonth = monthname($j);
            
/*      echo("\t\t\t\t<a href=\"news/old_news_list.php?month=$j&amp;year=".$i."\">$thisMonth</a><br />");*/ - THIS IS THE OLD LINE THAT WORKS BUT IT ONLY OPENS IN A BLANK PAGE NOT A POPUP

      
$winopen = "window.open('news/old_news_list.php?month=$j&amp;year=$i','',''width=700,height=500');return false;";
echo '<a href=""#" onclick="'.$winopen.'">'.$thisMonth.'</a>';
      echo "<br />";
            // If not last do a linebreak
            //if ($j != $monMin) { echo("<br />\n"); }
      }
      
      // Finish this year
      echo "\t\t\t</td>\n\t\t\n";
}

echo "\t</tr>\n</table>";

// Clean up
mysql_free_result($result) or die('Free result failed');
0
 

Author Comment

by:roscoeh23
ID: 17929183
anyone?
0
 
LVL 1

Accepted Solution

by:
Buraque earned 500 total points
ID: 17944996
can you try this one?
I tested it and it worked:

$text = "<a href='#' onclick=\"window.open('news/old_news_list.php?month=".$j."&year=".$i."','','width=700,height=500'); return false \">".$thisMonth."</a>";
echo $text;
 
0

Featured Post

Salesforce Has Never Been Easier

Improve and reinforce salesforce training & adoption using WalkMe's digital adoption platform. Start saving on costly employee training by creating fast intuitive Walk-Thrus for Salesforce. Claim your Free Account Now

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Returning errors to display in a dialog box - Ajax, Json, Php 16 54
PHP: Filling Out/Creating a PDF 29 109
$_GET call between URL 3 45
How do use '  ' within this code? 4 29
Nothing in an HTTP request can be trusted, including HTTP headers and form data.  A form token is a tool that can be used to guard against request forgeries (CSRF).  This article shows an improved approach to form tokens, making it more difficult to…
This article discusses how to create an extensible mechanism for linked drop downs.
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
The viewer will learn how to count occurrences of each item in an array.

726 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question