PHP Alert / Message box – Transparent & Cool! Javascript animated msgbox

Tired of using JavaScript’s ugly Alert() function? Or PHP’s Ugly die() function to display an error or message? You’re in the right place! I’ve prepared a complete Alert Box or Message Box suite to use in javascript or PHP. Checkout the Screen-shot:

Easy to Use!

Just include the source-path and call the my_alert() function with parameters! Lots of optional arguments to spice it up…. you can call same function either in javascript or PHP, it’s up to you! 😀

Full Demonstration and code examples

Checkout easy documentations here…

Free Download!

Download

Python Basics: Indent

Previous Article: Beginning Python Prgramming! How to Download, install, compile & run program in Python

In this post I’ll point out some details about the Python language. Important concepts to be clarified.

Python maintains indention strictly:

In python, you should maintain indention strictly! This is necessary to tell python which portion of code is under a block. For example, consider the loop segment below:

 

As you can see, there is no Curly-braces to identify where a loop starts and where ends! Thus, you must maintain indention strictly.

 

 

This entry will be updated eventually!

Automatic Mouse click, Key Press Script in Java

By Java, you can perform automatic mouse clicks, keyboard press etc. 🙂

I’ve created a short application by which you can make automatic mouse click in a certain co-ordinate! 😉

Download Source/Executable

Download from GoogleCode (source/executable)

Please note:  This is not any professional application, if you want to use professional mouse-recording or macro-recorder for presentation or other tasks, use other software.

If you want only to run the executable file, run the .jar file. You must have JRE installed in your computer 😉

How it works?

Java has a class Robot which dedicated for performing these activities. I simply used the class. More documentation here, and analysis the source code uploaded.

Add Dropdown Country & State List Dynamically into HTML form by Javascript

You can use a JavaScript to add all the country names and  state names’ Dropdown list. Which is actually done by HTMLand tag. I’ve written a JavaScript which can be simply inserted into your HTML file. Later, call my pre-defined functions and the country and state list will be automatically added into your HTML 🙂

Live Demo!

Check the code live here

How to use?

1. Copy the JavaScript code from the above link and save it in a file “countries.js”

2. Put this code between yourandsection:

<script type= "text/javascript" src = "countries.js"></script>

3. Put this code between yourandsection:

 Select Country (with states):   <select id="country" name ="country"></select>
Select State: <select name ="state" id ="state"></select>
 <script language="javascript">
populateCountries("country", "state");
 </script>

Please note that, we are using twotags, which are actual drop-down boxes. Here I’ve chosen “country” and “state” as theirID attribute. You can choose any othe id attribute or name attribute as you like. But whatever you choose, you make to pass the correct IDs when calling the JavaScript Functions.

If you only want Country list to appear on the page, Simply use following bit of code in Body section:

Select Country:   <select id="country2" name ="country2"></select>
<script language="javascript">
populateCountries("country2");
 </script>

Open a URL in new Browser window in Flex/ActionScript

ActionScript uses the function navigateToURL(var1:URLRequest,targetWindow:String ) to Open a URL link in a browser.

 

For the simplictiy, there goes a function. Just calling the function with the desired URL as String will open the URL in a new window.

public function jumpTo(jumpLoc:String):void
 {
 navigateToURL(new URLRequest(jumpLoc),"_blank");
 }

Usage:

Call the function defined above with the URL as a String-type parameter.
Example:

jumpTo("http://google.com");

Previously published at my Progmaatic Blog

String Replace Function in Flex ActionScript

There is a function String.replace() which returns the result string. But note, this only replaces the first occurance of given string/expression!

 

So, to actually replace all the occurances of given string/expression, you must loop through until all the matches are replaced. Code & Documentation

However, there is another easy customized function to automatically replace all the occurance of given match. Here goes the customized function:

public function str_replace(mainStr:String, str1:String, str2:String):String
 {
 var temp:Array = mainStr.split(str1);
 var tempStr:String = temp.join(str2);
 return tempStr;
 }

Usage:

var myStr:String = str_replace("a_b_c", "_" , "1");   // a1b1c1

Got Help From Source

Splitting Strings in Flex ActionScript: split method

Using Split method on a given String, you can get an array of Substrings. Each substring is formed from the given String by spliting them according to another given string, or expression. That means, the another string separates or splits the mother-String and split it into array of Substrings.

Example:

var myStr:String = "first_second_third";
var subStr:Array = myStr.split("_");

Now subStr[0] will contain “first”, subStr[2] will contain “third”;

More Practical Example:

package{
import flash.display.Sprite;
public class Main extends Sprite{
public function Main(){
var filename:String = "document.jpg";
var nameParts:Array = filename.split(".");
var extensionless:String = nameParts[0];
trace ("The filename is " + extensionless);
var extension:String = nameParts[1];
trace ("The file extension is " + extension);
}
}
}

You can see following Useful Links:

http://www.java2s.com/Code/Flash-Flex-ActionScript/String/Usesplitmethodtogetthefilenameanditsextensionname.htm

This article was previously published at my Progmaatic Blog.