views:

39

answers:

2

Hi there, can anybody help me here please? I am using AJAX for pagination in my application. So I am generating hyperlinks with for loop. as follow:

for($t=1; $t<=$hf; $t++)
{
   if($t == $_GET['pageno'])
   {    
       echo $t." ";
   }
   else
   {  
       echo "<a id ='$t' href='javascript:void(0)' onclick='open_page('ajaxinfo.php','content'); javascript:change('$t');'>$t</a>"." "; 
} 
 }

Above echo statement does not give call to function. But instead of this when i just write html hyperlink it works fine and I get to see page2.html, my HTML code is:

<a id="page2" href="javascript:void(0)" onclick="open_page('ajaxinfo.php','content'); javascript:change('page2');">page2</a>

I don't understand why this is so? But is there any problem in echo's quotes. Please Help.

A: 

You have to have code to add the contents returned by the ajax to the page. I don't see that anywhere.

paullb
A: 

that because you have syntax error while building anchors. Try to use double quotes for tag attributes and escape them with backslash.

So, your ECHO should look like this:

echo "<a id =\"{$t}\" href=\"javascript:void(0)\" onclick=\"open_page('ajaxinfo.php','content'); javascript:change('{$t}');\">{$t}</a> ";
Nazariy
using `printf` or a View Helper over that mishmash would be much smarter anyway
Gordon
Thank you Nazariy!!, I tried it but only for href, that's giving error. But now it's working. Learn t a new thing today. Thanks again.
Rishi2686