opening a javascript link in php -again

Posted on 2006-11-12
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="#"
return false \" >$thisMonth</a>');

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

Question by:roscoeh23
LVL 142

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=\"#\"
return false \" >$thisMonth</a>");
LVL 49

Expert Comment

ID: 17924730
What about using something like this:

$winopen = "'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.


Author Comment

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.



What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

LVL 49

Expert Comment

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


Author Comment

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 = "'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');

Author Comment

ID: 17929183

Accepted Solution

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

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

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Suggested Solutions

Consider the following scenario: You are working on a website and make something great - something that lets the server work with information submitted by your users. This could be anything, from a simple guestbook to a e-Money solution. But what…
Deprecated and Headed for the Dustbin By now, you have probably heard that some PHP features, while convenient, can also cause PHP security problems.  This article discusses one of those, called register_globals.  It is a thing you do not want.  …
Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…

747 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

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now