Thursday, September 25, 2008

how to change the alert box title?

Want to know how to change the alert box title in javascript...
the answer is: we cant change the title of js alert box.

however, we can use popup boxes, that look like alert boxes with custom title.... but there is a chance - some browsers will block that.
Or we can use vbscript msgBox, but cant get the result in FF.
Or we can use custom designs like this:
http://www.acejs.com/scriptsfolder/121015/121015.html

BUT it is not working like exactly as a alert box. (following codes will get executed though we dont click the ok button)

My opinion: Its better not to use any other custom alert boxes.

Wednesday, August 13, 2008

Change / Increase session timeout in php

Projects using login may have the problem of expiring sessions in short time.
How to increase the session timeout in PHP?

use this as first line - before session_start
ini_set('session.cookie_lifetime',(3600*2));

In some servers it may not work.... BUT using .htaccess file it is working very fine.
Just place these lines in the .htaccess file and put the file in your root directory.
php_value session.cookie_lifetime 3600
php_value session.gc_maxlifetime 3600

and note these parameters are in seconds.
Then how to check the current session timeout?
use this:
printf("cookie: %s, gc: %s", ini_get('session.cookie_lifetime'), ini_get('session.gc_maxlifetime'));

Thats all.

Wednesday, July 23, 2008

Audio Streaming / Playing audio mp3 files in web page - HTML

How to play mp3 files in a web page - as streaming using some players available for free?...

First, lets try with windows media player.
Try this code...
<object id="MediaPlayer" height=46 classid="CLSID:22D6f312-B0F6-11D0-94AB-0080C74C7E95" standby="Loading Windows Media Player components..." type="application/x-oleobject" codebase="http://activex.microsoft.com/activex/controls/mplayer/en/nsmp2inf.cab#Version=6,4,7,1112">
<param name="filename" value="Bheema1.mp3">
<param name="Showcontrols" value="True">
<param name="autoStart" value="True">
<embed type="application/x-mplayer2" src="http://www.mix26.com/demo/Bheema1.mp3" name="MediaPlayer"></embed>
</object>

will Show this media player:








This one is from google... Google audio player.
<embed type="application/x-shockwave-flash" src="http://www.google.com/reader/ui/3247397568-audio-player.swf?audioUrl=http://www.mix26.com/demo/om_zaraare.mp3" width="400" height="27" allowscriptaccess="never" quality="best" bgcolor="#ffffff" wmode="window" flashvars="playerMode=embedded" />

will Show:



This is from yahoo...
<embed src='http://webjay.org/flash/dark_player' width='400' height='40' wmode='transparent' flashVars='playlist_url=http://www.mix26.com/demo/marudhaani.mp3&rounded_corner=1&skin_color_1=0,0,0,0&skin_color_2=0,0,0,0' type='application/x-shockwave-flash' pluginspage='http://www.adobe.com/go/getflashplayer'/>

will Show:



And this one is very cute...
Add just a line (javascript) in your page and get the player...

http://mediaplayer.yahoo.com/

Cheers!

Random Number / Alpha Numeric Password Generation in PHP

To generate random no.s we can use rand() function...
try,
echo ran() ; //will generate random no between 0 and32768
echo rand(5,200); //a random no between 5 and 200

To generate alpha numeric random no - uniqid()...
try,
echo uniqid(rand(), true);
you can get a number like:
274134886dbd37292e8.16885304 (32 digit)

To generate alpha numeric passwords for user accounts use this:
$password = substr (MD5(uniqid(rand(),1)), 3, 10); //10 digit random alpha numeric password

Reference:
http://in.php.net/manual/en/function.rand.php
http://in.php.net/manual/en/function.uniqid.php
http://in.php.net/manual/en/function.md5.php

Cheers!

Friday, July 4, 2008

Doctype - margin / padding problem with HTML

Some may come across the problem...

<!DOCTYPE html PUBLIC....

if you use any doctype in our page, then some unwanted padding/margin will appear with images / tables / td s will be added automatically in your page....

You want to remove them...? Then add this css code in to your page

html, body, div, span, object, iframe,
h1, h2, h3, h4, h5, h6, p, blockquote, pre,
a, abbr, acronym, address, code,
del, dfn, em, img, q, dl, dt, dd, ol, ul, li,
fieldset, form, label, legend,
table, caption, tbody, tfoot, thead, tr, th, td {
margin: 0;
padding: 0;
border: 0;
}

Thats all...
Cheers!

Saving Textarea value with enter / Line feed / Line break in PHP

In save forms into database... the value in the text area cant be saved with the line feed that user gives.

To get them we can use the following function...

consider the textarea name is description.... then we can convert the line feed in the form of '\n' or '\r' into <br />

$desc = $_REQUEST['description'];
$desc = ereg_replace("(\r\n|\n|\r)", "<br />", $_desc);


Cheers!

Friday, June 27, 2008

Call Functions across parent and child windows using iframe

how to call child window(in iframe) function from parent window?
how to call parent window function from child window(in iframe)....

Simple.
From parent window.... framename.child_function_name()

From child window... parent.parent_function_name()


Demo

Download


Cheers!

Div over flash problem in HTML

Some may have this problem.
Always the flash object looks like placed in front of all the objects. So if we want to put a div in front of flash/ over flash we cant.

But there s a solution...
The normal flash object....
<object classid="clsid:D27CDB6E-AE6D-11CF-96B8-444553540000" id="obj1" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,40,0" border="0" width="519" height="255">
<param name="movie" value="center_flash.swf">
<param name="quality" value="High">
<embed src="center_flash.swf" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" name="obj1" width="519" height="255" quality="High">
</object>

To make it back of all elemnts add
<param name="wmode" value="transparent">


So the actual code we want is...
<object classid="clsid:D27CDB6E-AE6D-11CF-96B8-444553540000" id="obj1" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,40,0" border="0" width="519" height="255">
<param name="movie" value="center_flash.swf">
<param name="quality" value="High">
<param name="wmode" value="transparent">
<embed src="center_flash.swf" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" name="obj1" width="519" height="255" quality="High">
</object>

Demo

Download

Cheers!

Wednesday, June 18, 2008

Radio button validation in Javascript (HTML)

<html>
<head>
<meta http-equiv="Content-Language" content="en-us">
<title>Check Test</title>
<script language="javascript">
function valBox()
{
var x = document.chkForm;
var i, flg = 0;

for( i=0; i<x.grp.length; i++ )
{
if(x.grp[i].checked)
flg=1;
}
if(!flg)
{
alert("Select One");
return false;
}
}
</script>
</head>
<body>
<form name="chkForm" method="POST" action="#" onsubmit="return valBox();">
<div align="center">
<table border="0" cellpadding="0" cellspacing="0" width="100%" id="table1">
<tr>
<td><input type="radio" value="V1" name="grp">1</td>
</tr>
<tr>
<td><input type="radio" value="V2" name="grp">2</td>
</tr>
<tr>
<td><input type="radio" value="V3" name="grp">3</td>
</tr>
<tr>
<td><input type="submit" value="Submit" name="B1"></td>
</tr>
</table>
</div>
</form>
</body>
</html>