Skip to main content

JavaScript

---
var array = [0, 1, null, 2, "", 3, undefined, 3,,,,,, 4,, 4,, 5,, 6,,,,];

var filtered = array.filter(function (el) {
  return el != null;
});

console.log(filtered);
__________________________

Click on interval

setInterval(function () {document.getElementById("checkin_submit").click();}, 6000);
___________________________________________________

###Password Hide and show
feild-----
<input id="register_password" class="form-control" type="password" name="password" placeholder="Password" required><i  class="glyphicon glyphicon-eye-open eyemark" onclick="Toggle()" value="Show" ></i> 

Script----
$(".glyphicon-eye-open").on("click", function() {
$(this).toggleClass("glyphicon-eye-close");
  var type = $("#login_password").attr("type");
   var type2 = $("#register_password").attr("type");
if (type == "text"){
  $("#login_password").prop('type','password');}
else{
  $("#login_password").prop('type','text'); }
  if (type2 == "text"){
  $("#register_password").prop('type','password');}
else{
  $("#register_password").prop('type','text'); }
});
_________________________________________________________________

<script>
var today = new Date();
var dd = today.getDate();
var mm = today.getMonth()+1;
var yyyy = today.getFullYear();
if(dd<10)
{
    dd='0'+dd;
}

if(mm<10)
{
    mm='0'+mm;
}

today = mm+'/'+dd+'/'+yyyy;
console.log(today);
----

var date = new Date();

  var hours = date.getHours();
  var minutes = date.getMinutes();
  var ampm = hours >= 12 ? 'PM' : 'AM';
  hours = hours % 12;
  hours = hours ? hours : 12; // the hour '0' should be '12'
  minutes = minutes < 10 ? '0'+minutes : minutes;
  var strTime = hours + ':' + minutes + ' ' + ampm;

document.write(strTime);
</script>
----------------------
<!--  <script>
if (jQuery) {

   alert("jQuery library is loaded!");

} else {

   alert("jQuery library is not found!");

}

</script>  -->
_____________________________________________

<!DOCTYPE html>
<html>
<body>

<h2>JavaScript getFullYear()</h2>

<p>The getFullYear() method returns the full year of a date:</p>

<p id="demo"></p>

<script>
var d = new Date();
var newdate  = d.getFullYear()+'/'+d.getMonth()+'/'+d.getDate();
document.getElementById("demo").innerHTML  = newdate;
</script>

</body>
</html

---------------------------------------------------------------
<!DOCTYPE html>
<html>
<style>
#myProgress {
  position: relative;
  width: 100%;
  height: 30px;
  background-color: #ddd;
}

#myBar {
  position: absolute;
  width: 10%;
  height: 100%;
  background-color: #4CAF50;
}

#label {
  text-align: center;
  line-height: 30px;
  color: white;
}
</style>
<body>

<h1>JavaScript Progress Bar</h1>

<div id="myProgress">
  <div id="myBar">
    <div id="label">10%</div>
  </div>
</div>

<br>
<button onclick="move()">Click Me</button>

<script>
function move() {
  var elem = document.getElementById("myBar"); 
  var width = 10;
  var id = setInterval(frame, 38);
  function frame() {
    if (width >= 100) {
      clearInterval(id);
    } else {
      width++;
      elem.style.width = width + '%';
      document.getElementById("label").innerHTML = width * 1  + '%';
    }
  }
}
</script>

</body>
</html>
_______________________________________________________

## ROUND FLOAT VALUE UPTO n PLACES
value.toFixed(n);

## The splice() method adds/removes items to/from an array, and returns the removed item(s).
<button onclick="myFunction()">Try it</button>
<p id="demo"></p>

<script>
var fruits = ["Banana", "Orange", "Apple", "Mango"];
document.getElementById("demo").innerHTML = fruits;

function myFunction() {
  fruits.splice(1, 2,"vinay");
  document.getElementById("demo").innerHTML = fruits;
}
</script>

_______________________________________________________




Comments

Popular posts from this blog

SETUP REST API IN CI

1. Create Rest_controller.php inside controllers and paste code: <?php defined('BASEPATH') OR exit('No direct script access allowed'); require APPPATH . '/libraries/API_Controller.php'; class Rest_controller extends API_Controller { public function __construct() { parent::__construct(); } public function index() { $this->api_return(             [ 'status' => true,                'result' => "Welcome to Testservices."             ],         200); } } ?> 2. Create api.php inside config and paste code : <?php defined('BASEPATH') OR exit('No direct script access allowed'); /**  * API Key Header Name  */ $config['api_key_header_name'] = 'X-API-KEY'; /**  * API Key GET Request Parameter Name  */ $config['api_key_get_name'] = 'key'; /**  * API Key POST Request Parameter Name ...

Array Difference, Radio Button Js,

$a1=array("a"=>"red","b"=>"green","c"=>"blue","d"=>"yellow"); $a2=array("e"=>"red","f"=>"green","g"=>"blue"); $result=array_diff($a1,$a2); print_r($result); ______________________________________________________ <script type="text/javascript">  $(document).ready(function(){       $("input[type='radio']").click(function(){             var radioValue = $("input[name='duration']:checked").val();             if(radioValue){                 alert("Your are a - " + radioValue);             }         });  }); </script>   $(document).on("click", ".upappdesc", function(){ // alert($(this).data('id'));  var option = $(this).data("cat").split(",");  // alert($(this).data(...

KrutiDev To Unicode Conversion

http://wrd.bih.nic.in/font_KtoU.htm ___________________________________ <html> <head> <title>KrutiDev <=> Unicode Conversion</title> </title> <link rel="stylesheet" href="style.css">       <script src='script.js'></script> </head> <!--       body of the HTML starts here. one text box is provided each for input and output. --> <body bgcolor='#99CCFF'> <P style='text-align:center; font-family: Arial, Helvetica, sans-serif; font-size: 14pt; font-weight:bold; background-color: #FF6600; color: #FFFFFF'> Conversion between Krutidev-010 and Unicode क्रुतिदेव-०१० और यूनिकोड के बीच रूपांतरण </P> <form name="form1"> <p style='font-size:10pt'>क्रुतिदेव-०१० (Kruti Dev 010) फॉन्ट में टंकिट टेक्स्ट को "क्रुतिदेव-०१०" नामक टेक्स्ट बॉक्स में टाईप या पेस्ट करें तथा इसे यूनिकोड में रूपांतरित करने के लिए अधोमुख तीर वाल...