Developer Blog

You are currently browsing the ash.MVC Blog weblog archives for December, 2006.


Archive for December, 2006

Printing a webpage

Wednesday, December 6th, 2006

Webpage can be printed using window.print(). Here is the code:

<a onclick="window.print(); return false" href="http://ash-mvc.org/blog/webpage.html">Print This Page</a>

“return false” cancels the link to “webpage.html”.

When the hyperlink “Print This Page” is clicked, the page is printed if the printer is already installed.

Assign PHP array content to a JavaScript array

Wednesday, December 6th, 2006

Sometimes we need to transfer the server side data to client side. Means we may need to transfer PHP variable or array values to Javascript variable or values. The following script will solve this problem very well.

$aDatas = array();
$aTitles = array();
$iMaxCount = 10;
for($iCount=0; $iCount< $iMaxCount; $iCount++)
{
 $aDatas[$iCount] = $iCount +10;
 $aTitles[$iCount] = 'Title'. $iCount;
}

?>

Make sure that you have given single quote before and after PHP tag, while assigning STRING values from PHP variables to JS.

Get Download Files Review Project Dashboard Know Plan And Wishlist