Archive for : July, 2011

Javascript print array elements and print object

Print array elements with javascript:

var output = '';
for(var i=0; i < arr.length; i++){ output += "arr[" + i + "] = " + arr[i] + ";"; } alert(output);

Print object with javascript:

var output = '';
for (property in object) {
output += property + ': ' + object[property] +'; ';

Javascript – open a popup window using

The syntax of the

open (URL, windowName[, windowFeatures])

example: ("","G31zone"); ("", "G31zone","status=1,toolbar=1");


status The status bar at the bottom of the window.
toolbar The standard browser toolbar, with buttons such as Back and Forward.
location The Location entry field where you enter the URL.
menubar The menu bar of the window
directories The standard browser directory buttons, such as What’s New and What’s Cool
resizable Allow/Disallow the user to resize the window.
scrollbars Enable the scrollbars if the document is bigger than the window
height Specifies the height of the window in pixels. (example: height=’350′)
width Specifies the width of the window in pixels.

Verify if a checkbox is selected (checked) with jQuery

Verify if a checkbox is selected (checked) with jQuery

<form name="my_form_name" id="my_check_box">
<input type="checkbox" name="my_check_box" id="my_check_box">
<script type="text/javascript">
jQuery(document).ready(function() {
jQuery('#my_check_box').click(function () {
if (jQuery(this).is(':checked'))
alert('My checkbox is checked');

jQuery – prevent form submitting

Method to prevent form submitting using jQuery:

<form method="post" name="my_form_name" id="my_form_id">
<input type="submit" value="Go">
<script type="text/javascript">
jQuery('#my_form_id').submit(function() {
alert('Prevent form submitting.');
return false;