JavaScript Tutorials

Randomize an array in javascript

This is the sample post of randomize array concept in javascript;In the below example i will show you to randomize an array using its position in java script.var _arrayOne=[1,2,3,4,5,6,7]; var _arrayTwo=[27,26,24,23,29,28,25]; var _randArrayOne=[]; var _randArrayTwo=[]; function random(){ document.write("Before Randomize"); document.write('\n'); document.write(_arrayOne); document.write('\n'); document.write(_arrayTwo); document.write('\n'); for(var i=0; i < 7; i++) { var _random = Math.round(Math.random()*(_arrayOne.length-1)); _randArrayOne.push(_arrayOne[_random]); _randArrayTwo.push(_arrayTwo[_random]); _arrayOne.splice(_random,1); _arrayTwo.splice(_random,1); } document.write("After Randomize"); document.write('\n'); document.write(_randArrayOne); document.write('\n'); document.write(_randArrayTwo); }... Read More »

Redirect Page In Javascript

ASSIGN REDIRECT URLREDIECT TO GO BACKWINDOW NAVIGATIONWINDOW LOCATION REPLACEI added the code to redirect the page using javascriptASSIGN REDIRECT URL <script language="javascript" type="text/javascript"> window.location.href=REDIRECTURL; //or window.location=REDIRECTURL; </script> REDIECT TO GO BACK <script language="javascript"> alert("Go Back"); window.history.back(-1); </script> WINDOW NAVIGATION <script language="javascript"> window.navigate(REDIRECTURL); </script> WINDOW LOCATION REPLACE <script language="javascript"> window.location.replace(REDIRECTURL); </script>... Read More »

Java Script Function To Return Selected Checkbox Value

Get the selected checkbox value from the group of checkbox list in Javascript. I wrote one function to return the selected checkbox value in Javascript. <script type='text/javascript> // Java Script function to return the selected checkbox value function Checkbox_Selection_Value_From_Group (){ fileid= $(\"input[name='filegroup[]']:checked\").map(function() { return this.value; }).get(); if(fileid==''){ alert('Select Minimum One Check Box'); return false; }else{ // You Will get comma separated value // 1,2 return 'id='+fileid; } } </script> <input […]... Read More »