Archive for March, 2012

fix record for table

echo”<table border=\”0\” cellspacing=\”0\” celpadding=\”0\”>\n”;
$i=1;
while($i<=10)
{
$html2=”;
if($i%3==0)
{

$html.=”\n<td>”.$i.”</td>\n”;
$html2=”\n<tr>$html</tr>\n”;
echo $html2;
$html=”;
}else
{
$html.=”\n<td>”.$i.”</td>”;
}

$i++;
}

echo “</table>”;

check sector hidden or visible with jquery

if ( $('#myDiv').is(':hidden') ) {
   //do something I am hidden!
   alert("i am hidden!");
}
if ( $('#myDiv').is(':visible') ) {
   //do something I am :visible!
   alert("i am visible!");
}

jquery mask

his is a masked input plugin for the jQuery javascript library. It allows a user to more easily enter fixed width input where you would like them to enter the data in a certain format (dates,phone numbers, etc). It has been tested on Internet Explorer, Firefox, Safari and Chrome.

http://stackoverflow.com/questions/9763553/jquery-mask-dependent-on-drop-down-value

http://digitalbush.com/projects/masked-input-plugin/

 

 

$('#country').change(function () {
    var $selected = $(this).find('option:selected');
    if ($selected.val() === 'US') {
        $("#postal_code").mask("99999");
    } else {
        $("#postal_code").mask("a9a-9a9");
    }
});
<select id="country" name="country">
<option selected="selected" value="0"></option>
<option value="CA">Canada</option>
<option value="US">United States</option>
</select>

<input type="text" id="postal_code" name="postal_code" />

jQuery – Post array of multiple checkbox values to php

<script type="text/javascript">
function calculate() {

    var arr = $.map($('input:checkbox:checked'), function(e, i) {
        return +e.value;
    });

    $('span').text('the checked values are: ' + arr.join(','));
}

$(document).ready(function(){

calculate();

$('div').delegate('input:checkbox', 'click', calculate);

});

</script>
<div>
    <input type="checkbox" checked="checked" name="options[]" value="1" />
    <input type="checkbox" name="options[]" value="2" />
    <input type="checkbox" name="options[]" value="3" />
    <input type="checkbox" checked="checked" name="options[]" value="4" />
    <input type="checkbox" name="options[]" value="5" />
</div>
<span></span>
From :http://stackoverflow.com/questions/1557273/jquery-post-array-of-multiple-checkbox-values-to-php

Hack CSS all Browser

1.IE

.className
{
padding:10px/; IE9 + IE8

}

@media all and (min-width:0) {
.className { color:pink /; }  /* IE9 */
}

.className{padding:10px\9;} /* IE8 — */

.className{padding:10px;} /* IE8 */

.className{*padding :10px ;} /* IE7 — */

OR

* + html .class{margin-left:20px;} /* IE7 */

.className{_padding :10px ;}  /* IE6 — */

OR

* html .logo{margin-left:10px;} /* IE6 */

2.Firefox

html>/**/body .className{margin-left:10px}

OR

@-moz-document url-prefix() {
.className {{font-size: .6em;}}

html>/**/body .className, x:-moz-any-link, x:default {background:red;} /* Firefox 3 */

3.Chrome
body:nth-of-type(1) .className{margin:20px;}
OR:
@media screen and (-webkit-min-device-pixel-ratio:0) {
.className{ margin:0 26px 0 0; }
} /* hacked cho chrome và safari */

4.Safari
@media screen and (-webkit-min-device-pixel-ratio:0)
{ .className { margin:10px; } }

5.Opera
@media all and (min-width:0px) {head~body .className {margin-left:10px;}}

each addClass in tag

$(‘tr’).each(function() {
$(‘tr td img’).addClass(‘clasimage’);
});

Practical solutions concerning the use of the .htaccess file

1.Forbidding a particular file:
<Files config.inc.php>
order allow,deny
deny from all
</Files>

2.Forbidding a particular file inc:
<Files ~ "\.inc$">
  Order allow,deny
  Deny from all
</Files>
3.Hide and deny files
<Files ~ "^\.ht">
  Order allow,deny
  Deny from all
  Satisfy All
 </Files>

Hide and deny files