Archive for May, 2006

Resize Image on the fly

May 18th, 2006

Hi,

I have recieved many queries from people asking , how can they resize image in the fly using php.

Today I will explain how we can do it , but before we jump into code it has some prerequisite and constraint:

1) GD library should be installed on your server.

2) It works with only jpg and gif images.

IF you wondering how to make sure GD library is installed on your server , use the code below-

function GDCheck()
{
echo ” Status of GD support on your server: “;

// Check if the function gd_info exists (great way to know if gd is installed)
if(function_exists(“gd_info”))
{
echo “YES”;
$gd = gd_info();

// Show status of all values that might be supported(unsupported)
foreach($gd as $key => $value)
{
echo “–” . $key . “: “;
if($value)
echo “YES”;
else
echo “NO”;
}
}
else
echo “NO”;
}

GDCheck();
?>

None yet

Print multiple pages with single click..

May 13th, 2006

Only by loading a framset with all four pages loaded – with the onLoad event handler in the frameset using the window print method to print each frame:
[form]
[input type="button" onClick="if (window.print) location.href='printframeset.htm'"]
[/form]
And then in printframeset.htm:
[html]
[head]
[script language="JavaScript"][!--
function printAll() {
for (var i=0;i[frames.length;i++)
if (window.print)
frames[i].print();
}
//–][/script]
[/head]
[frameset onLoad="printAll()" rows="*,*,*"]
[frame xsrc="apage.htm" mce_src="apage.htm" ]
[frame xsrc="anotherpage.htm" mce_src="anotherpage.htm" ]
[frame xsrc="yetanotherpage.htm" mce_src="yetanotherpage.htm" ]
[/frameset]
[/html]
The previous script has been reported not to work on some platforms (it works perfectly on Netscape Navigator 4.7 on Linux). I assume on some platforms only one print dialogue box at a time can be opened. It might be possible to overcome this with a setTimout, but its going to be difficult to know when to start another one. A set delay of, say, 5 seconds might be too short if the user doesn’t hit the print button. Anyway try:
[html]
[head]
[script language="JavaScript"][!--
function printAll() {
for (var i=0;i[frames.length;i++)
if (window.print)
setTimeout('frames[' + i + '].print()’,5000 * i);
}
//–][/script]
[/head]
[frameset onLoad="printAll()" rows="*,*,*"]
[frame xsrc="apage.htm" mce_src="apage.htm" ]
[frame xsrc="anotherpage.htm" mce_src="anotherpage.htm" ]
[frame xsrc="yetanotherpage.htm" mce_src="yetanotherpage.htm" ]
[/frameset]
[/html]

Note; Repleace[ .] with <,> in code

None yet

How to call javascript function from PHP Code

May 10th, 2006

Hi All,

I am back with more tips and tricks of Javascript, to make it “fun with Javascript” . Contrary to common layman notion that javascript is not user friendly or not very reliable, it is very reliable and user friendly. Sample this even google and Yahoo use them in there application, this shows the reliabilty and flexibilty Javascript offer.

Today I shall discuss “how can we call Javascript function from PHP code without any click event happening on our page”

Here is sample code:

Write you Javascript function in HEAD

/HEAD/
/SCRIPT LANGUAGE=”javascript”/
function ProcA () {
alert (“message”);
}
//SCRIPT/
//Head/

Calling this function from PHP code -for instance based on a decision.

if ($decision==’true’) {
echo “/SCRIPT LANGUAGE=”javascript”/”;
echo “FunctionA;n”;
echo “//SCRIPT/
}
?>

P.S- repleace / with < or > whereever applicable.

Code End here///////////////////

That simple noooooooo:)

If you have any question/queries. Contact us at www.varshyltech.com

None yet

Calling two function on one click…

May 10th, 2006

Hi All,

Today I will talk about how can we call two javascript function on one button click.

I have seen many case while doing website designing that many times we get situation where we want to check/validate couple of things on one button click, contrary to general notion people have it is very much possible and very easy. It is same way we call single function , except a ‘;’ between two function we want to call on button click.

Following sample code will give you an example: here two function are called on ‘Submit’ button clik.
input type=”button” value=”Submit” onClick=”function1(parameter1);function1(parameter1)”

////end here

this is it! simple and short:)

-Harish Sharma

Varshyl Tech

None yet

JavaScript to validate input value is an Integer

May 3rd, 2006

JavaScript Validation: Script to validate input value is an Integer.

We will use Regular Expression and exec() function to do the validation.

Sample Code:

//Code for Form which captures click event and calls ‘validate()’ function.

//function validate()

// {

//frm = document.form

//var freg = /(^\d\d*$)/;

// var Intval = frm.text.value;

//if(!fr.exec(Intval))

// {

// alert(“Only Integer Value allowed”);

// return false;

// }

// }

——————————————-

Code Explanation:
Create a Regular Expression variable
var freg = /(^\d\d*$)/;

Use exec function to see if it matches regular expression – if it return ‘False’ show the message and return false.
if(!fr.exec(Intval))

That’s it. Hope this help you guys :-)

Advertisement: Varshyl Tech offers website designing, logo designing, Search engine promotion, custom software development solutions.

only 1