Posts

Showing posts from October, 2014

on select box change reload same page.

   <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.6.0/jquery.min.js"></script>                     <script src="js/jquery-1.7.2.min.js" type="text/javascript"></script>                     <script type="text/javascript"> $(document).ready(function() {     $("#currency").change(function() { var id = $(this).val();         $.ajax({             url: 'current.jsp',             type: 'POST',             data:{'id':$(this).val()},             success: function(data)             {         location.reload();             }         });     }); }); </script>  <select name="currency" style="height:20px;font-size:9px;margin:-7px -2px -13px 5px;   padding:3px 12px 2px 17px;" id="currency">             <option value="">Select Currency</option> Check this for live t
Image

print a div through javascript.

<script type="text/javascript">         $("#btnPrint").live("click", function () {             var divContents = $("#dvContainer").html();             var printWindow = window.open('', '', 'height=400,width=800');                       printWindow.document.write(divContents);                       printWindow.document.close();             printWindow.print();         }); </script>

hidden div.

<div id="dvContainer" style="display: none;visibility: hidden; background-color:#F00; width:1000px; height:1000px;"> </div>

MyLinear Search.

public class MyLinearSearch {     public static int linerSearch(int[] arr, int key){                 int size = arr.length;         for(int i=0;i<size;i++){             if(arr[i] == key){                 return i;             }         }         return -1;     }         public static void main(String a[]){                 int[] arr1= {23,45,21,55,234,1,34,90};         int searchKey = 34;         System.out.println("Key "+searchKey+" found at index: "+linerSearch(arr1, searchKey));         int[] arr2= {123,445,421,595,2134,41,304,190};         searchKey = 421;         System.out.println("Key "+searchKey+" found at index: "+linerSearch(arr2, searchKey));     } }