All posts by WhiteWind

About WhiteWind

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

How to set method of a html form using javascript or js?

It can be done as follows :

document.forms["Form_Name"].method= "get";
or
document.forms["Form_Name"].method= "post";

How to set action for a form using javascript or js?

It can be done as follows :

document.forms["Form_Name"].action = "file_name.ext";

It can be followed in any programming language. It’s tested and working. Tested by myself

How to stop exit an exicuting loop while it meets an inner condition?

We use last for exiting from an execution loop.

It’s as follows :

for(my $m=0;$m<=$country_tot;$m++) {
    if($country_id[$m]==$row_detail->{country}) {
         $cntry=$country_name[$m];
         last;
    }
}

How to implement “select all” check box using js in HTML?

It can be implemented as follows…

<input id="my_selectall" style="box-shadow: 0px 0px 0 0; width: auto;" onclick="mycheck()" type="checkbox" /> Sl No.
<input style="box-shadow: 0px 0px 0 0; width: auto;" type="checkbox" name="case" value="1" /> 1
<input style="box-shadow: 0px 0px 0 0; width: auto;" type="checkbox" name="case" value="2" /> 2
<input style="box-shadow: 0px 0px 0 0; width: auto;" type="checkbox" name="case" value="3" /> 3
<input style="box-shadow: 0px 0px 0 0; width: auto;" type="checkbox" name="case" value="4" /> 4
<script type="text/javascript">
    function mycheck() {
        var source=document.getElementById('my_selectall');
        checkboxes = document.getElementsByName('case');
        for(var i=0, n=checkboxes.length;i<n;i++) {
            checkboxes[i].checked = source.checked;
        }
    }
</script>

Get the column names from table in database(DB)

To get the table column name from the database, we should use the following SQL query:

SHOW COLUMNS FROM table_name;

To get the values in perl we can use the following code:

my $sql_rep_x = 'SHOW COLUMNS FROM '.$table;
my $getkey_x = $dbh->prepare($sql_rep_x);
$getkey_x->execute;
while( my @row_x = $getkey_x->fetchrow_array ) {
    push @names, $row_x[0];
}
$getkey_x->finish;