Monday, August 25, 2008

How to make javascript sub menus appear above flash objects?

Flash objects are considered to be "windows" on top of the browser and this is why they cover the submenus by default.
This can be easily changed by making the chnages to the HTML code.
The solution is to add a "opaque" attribute to the "<param>" parameter and "transparent" parameter inside your Flash object definition, as shown on the example below:

<object classid="clsid:166B1BCA-3F9C-11CF-8075-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/director/sw.cab#version=10,1,1,0" width="806" height="200">
<param name="WMode" value="opaque">
<param name="movie" value="/images/header/test.swf">
<param name="quality" value="high">
<embed src="/images/header/test.swf" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" width="806" height="200" wmode="transparent"></embed>
</object>

By adding the "Opaque" & "Transparent" parameter on both locations the submenus will always appear above Flash objects on all browsers.

How to change the font attributes dynamically using Javascript?

HTML code example:

<div align="center">
<font size="2" face="Times New Roman" color="#000000" id="field1"> Field Lable </font></p>
</div>

In the input box, you could call the function ChangeFont(size)

<SCRIPT LANGUAGE="JavaScript">
<!-- Heres the code to change the font
function ChangeFont(size)
{
text2.style.fontFamily="Arial";
text2.style.fontSize=size;
}-->
</SCRIPT>

Thursday, June 05, 2008

How to output a number with leading zero's?

Simple:

$number = 15;
printf("%05d", $number);

How do I set the browser timeout?

If your script is too complex to finish within the standard 30 seconds you can set a new value with the function:

set_time_limit(900);

this sets the timeout too 900 seconds / 15 minutes.

How do I format a number in a corect way?

You can use the number_format() function, you can find more information about the function in the PHP manual.

How to send HTML mail with php?

You would need to add a HTML content type to your mail header, as shown below:

mail($recipient, $subject, $message, From: $sender\nContent-Type: text/html;);

When I try to connect to mysql from php I get this error: "Call to unsupported or undefined function mysql_connect();"

Either you are missing mysql support in the php module or you need to load mysql dynamicly in your scripts by inserting:

dl("mysql.so"); (on unix)
dl("mysql.dll"); (on windows);

in the top of all the scripts that use mysql.

But it is recommended to compile php with mysql.