Friday, June 27, 2014

set hiddenfield value in jquery

  function BindSessionId(id) {
            $('input[id$=hdfsessionid]').val(id);
        }

Wednesday, June 25, 2014

Get Year Only from date in javascript

var startYear = new Date().getFullYear();

Append in jquery

<!DOCTYPE html>
<html>
<head>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<script>
$(document).ready(function(){
  $("#btn1").click(function(){
    $("p").append(" <b>Appended text</b>.");
  });

  $("#btn2").click(function(){
    $("ol").append("<li>Appended item</li>");
  });
});
</script>
</head>

<body>
<p>This is a paragraph.</p>
<p>This is another paragraph.</p>
<ol>
<li>List item 1</li>
<li>List item 2</li>
<li>List item 3</li>
</ol>
<button id="btn1">Append text</button>
<button id="btn2">Append list items</button>
</body>
</html>

Sunday, June 22, 2014

Remove all commas from string in jquery

 var income = $("#txtincome").val(); //12,000
 income = income.replace(/\,/g, '');//12000

Friday, June 20, 2014

make checkbox checked in jquery on dropdown on change

 $("#ddlCladded").change(function () {
            var ddlCladdedval= parseInt($("#ddlCladded").val());
            if(ddlCladdedval==1){
                     $('#chkCladded').prop('checked',true);
            }
            else{
                     $('#chkCladded').prop('checked',false);
            }        
        });

dropdown on change event and current dropdown value

 $("#ddlCladded").change(function () {
            var ddlCladdedval= parseInt($("#ddlCladded").val());
         
        });

Thursday, June 19, 2014

check if string is empty in javascript

function isEmpty(str) {
            return (!str || 0 === str.length);
        }