RSS
people

Javascript select a div content

How to using a javascript command to select and deselect a div tag content?
As I know, we can use a select() funtion to select text field value:
document.getElementById(‘username’).select();
But the above example does not work for a div or span tag.

For the div or span tag, it is pretty simply, just few lines command will do.
read more »

No Comments | Tags: ,

Dynamic wizard form using dhtml & javascript.

Recently I am working in a project that require some customization on the application.
They need a wizard page that will allow user to add in items.

To make the wizard page be more user friendly, I try to using dynamic html to create fields if required.
When user add in a item, the page will create a row in a table & display item’s information inside the table.
User are able to delete the item after add in.
It is not a hard task. Just sharing my experience to others.

I am using the createTextNode, createElement and removeChild Javascript command to complete the task.

Below is my sample code: read more »

1 Comment | Tags: , , , , ,

Javascript string replace all

In PHP, str_replace will replace all the occurrence key in a string to the value that specified by user.
In Javascript, if you using a replace function without specified, it will only replace the first occurrence of the key in the string to the value.

For example :

<script>
var js_str = "Visit RedHat now & RedHat will give out free gift to you";
js_str.replace("RedHat","how2guru");
alert(js_str);
</script>

The output of the above script will give you :
Visit how2guru now & RedHat will give out free gift to you 
 
If you would like to replace all the occurrence key to the value, you have to use the global match. It will replace all the occurrence key.
read more »

3 Comments | Tags: ,

Detect & trigger action while user exit webpage

Some of website developers are need to track on visitor’s activity during browsing their website. Even would like to track when the visitor exit or quit their website.

Below is a simple example on how to using a javascript command to track on visitor exit/close page action.

read more »

10 Comments | Tags: ,