Tuesday, January 23, 2007

How to get contents of a remote URL using PHP?

/************** Method 1 ******************/
$request = 'www.remoteurl.com';
$response = file_get_contents($request);
/************** Method 1 ******************/

/************** Method 2 ******************/
$filename = "www.remoteurl.com";
$handle = fopen($filename, "rb");

$response="";

if ($handle) {
while (!feof($handle)) {
$response .= fgets($handle);
}
fclose($handle);
}
/************** Method 2 ******************/

Read this article to know the PHP code performance...

http://www.phplibrairies.com/tutorial_2_page_1_en.html

Monday, January 08, 2007

How to make the available options of select box as selected while submitting a form using javascript?

for(var i = 0;i < document.formname.selectboxname.length;i++) {
document.formname.selectboxname.options[i].selected = true;
}

How to check whether atleast one checkbox is checked out of multiple checkboxes in a form?

Example:

var selected=false;

for(var i=0; i<frmname.Days.length; i++)
{
if(frmname.Days[i].checked==true)
{
selected=true;
}
}

if(selected==false) {
alert("Please select atleast one");
return false;
}

How to get confirmation before submitting a form using javascript?

var agree=confirm("Are you sure you wish to continue?");

if (agree) {
return true;
} else {
return false ;
}