All posts by WhiteWind

About WhiteWind

I'm a Perl-PHP Developer from India. I'm a great fan of Wordpress & Perl.

How to add an element at the end of the array?

It’s as follows :

 


@coins = ("Quarter","Dime","Nickel");
push(@coins, "Penny");

O/p

@coins = Quarter Dime Nickel Penny

how to Select All / Deselect All options in multiple select box using java script?

It’s as follows :

 

function listbox_selectall(listID, isSelect) {
        var listbox = document.getElementById(listID);
        for(var count=0; count < listbox.options.length; count++) {
            listbox.options[count].selected = isSelect;
    }
}

 

onclick="listbox_selectall('countryList', true)" //select all the options

(or)

onclick="listbox_selectall('countryList', false)" //deselect all the options

how to get multiple selected values and items from listbox using javascript?

It’s as follows :

 

var src = document.getElementById('leftSelect');
var selected = [];
var options = src.options.length;
for (var i=0; i < options ; i++)
{
     if(src.options[i].selected)
     {
          alert(src.options[i].text);
          alert(src.options[i].value);
     }
}

 

<html>
<select id="leftSelect" onclick="" name="edu_quli" size="10" multiple="multiple">
<option value="10th">10th</option>
<option value="+2">+2</option>
<option value="Any Graduation">Any Graduation</option>
<option value="Any Post Graduation">Any Post Graduation</option>
<option value="Arts Post-Graduation">Arts Post-Graduation</option><option value="Science Post-Graduation">Science Post-Graduation</option>
<option value="Commerce Post-Graduation">Commerce Post-Graduation</option>
<option value="Technical/Professional Post-Graduation">Technical/Professional Post-Graduation</option>
<option value="Management Post-Graduation">Management Post-Graduation</option>
<option value="Other Post-Graduation">Other Post-Graduation</option>
<option value="Diploma">Diploma</option>
<option value="Others">Others</option>
</select>
</html>

How to get array length in perl?

It’s as follows :

 

#!/uer/bin/perl

@array = (1,2,3);
$array[50] = 4;

$size = @array;
$max_index = $#array;

print "Size:  $size\n";
print "Max Index: $max_index\n";

O/P

Size: 51
Max Index: 50

How to submit a html form using javascript or JS?

It can be done as follows :

document.forms["Form_Name"].submit();