Friday 19 April 2013

Add Animated marks to Google Maps in the web page



<head>
<title>Add Animated marker to Google Maps in asp.net website</title>
<style type="text/css">
html { height: 100% }
body { height: 100%; margin: 0; padding: 0 }
#map_canvas { height: 100% }
</style>
<script type="text/javascript"
</script>
<script type="text/javascript">
function initialize() {
var myLatlng = new google.maps.LatLng(28.635308000000000000,77.224960000000010000)
var mapOptions = {
center: myLatlng,
zoom: 8,
mapTypeId: google.maps.MapTypeId.ROADMAP,
marker: true
};
var map = new google.maps.Map(document.getElementById("map_canvas"), mapOptions);
var marker = new google.maps.Marker({
position: myLatlng,
animation:google.maps.Animation.BOUNCE,
title: "New Delhi"
});
marker.setMap(map);
}
</script>
</head>
<body onload="initialize()">
<form id="form1" runat="server">
<div id="map_canvas" style="width: 500px; height: 300px"></div>
</form>
</body>
</html>


Wednesday 17 April 2013

Blink Color Text Font in HTML through Javascript


This JavaScript function tested in all Browsers like:  IE,Chrome,Firefox,Opera,Safari  

 <script type="text/javascript">

        window.setInterval (BlinkIt, 550);
        window.setInterval (BlinkIt1, 300);
        var color0 = "#1F1FFF";
        var color1 ="#FF3300";
        var color2 ="Orange";
        function BlinkIt () {
            var blink0  = document.getElementById ("blinkdata");
            color0 = (color0 == "#1F1FFF")? "Black" : "#1F1FFF";
            blink0.style.color = color0;

        }
        function BlinkIt1 () {
            var blink1 = document.getElementById("blinkadd");
            color1 = (color1 == "#FF3300")? "Black" : "#FF3300";
            blink1.style.color = color1;  
          }
   
    </script>

   <Strong> <p id="blinkadd"> Welcome in ramsis-code blog </p> </strong>

Tuesday 16 April 2013

HTML form with Jqurey Validation


<script type="text/javascript" src="js/jquery-1.8.0.js"></script>
<script type="text/javascript" src="js/jquery.ui.datepicker.js"></script>
<link rel="stylesheet" type="text/css" href="css/ui-lightness/jquery-ui-1.8.23.custom.css" />
<script type="text/javascript" src="js/jquery-ui-1.8.23.custom.min.js"></script>
<style type="text/css">
       .ui-datepicker
       {
           font-size: 8pt;
           font-family: Verdana;
       }       
</style>
<style type="text/css">
.textn{
font-family : Tahoma,Verdana, Geneva, Arial, Helvetica, sans-serif;
font-size : 12px;
font-style : normal;
font-variant : normal;
color:#000000;
}
input{
border: 1px solid;
background-color: #ffffff;
border-color: #13A9FF;
font-family: verdana;
font-size: 12px;
font-weight: normal;
}
select{
border: 1px solid;
background-color: #ffffff;
border-color: #13A9FF;
font-family: verdana;
font-size: 12px;
font-weight: normal;
}
textarea{
border: 1px solid;
background-color: #ffffff;
border-color: #13A9FF;
font-family: verdana;
font-size: 12px;
font-weight: normal;
}
#trOdd{
background-color: #F4BE2C;
}
#trEven{
background-color: #F4BE2C;
}
#tdCount{
background-color: #F4BE2C;
}
#divBrDetails{r
background-color: White;
display:block;
width:350px;
height:75px;
position:relative;
border: 1px solid #13A9FF;
margin: 2px 2px 2px 2px;
padding: 2px 5px 2px 5px;
font-size: 10px;
font-family: tahoma,Verdana, Geneva, Arial, Helvetica, sans-serif;
font-variant: normal;
font-weight: normal;
color: black;
z-index: 101;
}
.txtsuper{
font-family : Tahoma,Verdana, Geneva, Arial, Helvetica, sans-serif;
font-size : 13px;
font-style : normal;
font-variant : normal;
color: Red;
font-weight: bolder;
}
 </style>

<script type="text/javascript">
$(document).ready(function(){
NumberValidate();
AplhabetsValidate();
$(".require").each(function() {
if($(this).attr('class') === "numeric")
{
NumberValidate();
}
$(this).change(function() {
Validate();
});
});
$("select").each(function() {
$(this).change(function() {
Validate();
});
});
function NumberValidate(){
$(".numeric").each(function() {
$(this).keydown(function (evt){
var charCode = (evt.which) ? evt.which : event.keyCode;
if ((charCode != 8 && charCode !=9)&&(charCode < 37 || charCode >39)&&(charCode < 95 || charCode > 105)&&(charCode < 48 || charCode > 57)&&(charCode !=40)){
var error = "#lbl-"+$(this).attr('id').split('-')[1];
$(error).html('Only Numeric values allowed.');
$(this).css('border-color','red' ).css('border-width','2px');
return false;
}else {
var error = "#lbl-"+$(this).attr('id').split('-')[1];
$(error).html('');
$(this).css('border-color','' ).css('border-width','');
return true;
}      
});  
});
}
<!-- character only event validation  -->
function AplhabetsValidate(){
$(".alphabet").each(function() {
$(this).keydown(function (evt){
var charCode = (evt.which) ? evt.which : event.keyCode;
if ((charCode != 8 && charCode !=9)&&(charCode != 20 && charCode !=46)&&(charCode < 37 || charCode >39)&&(charCode < 65 || charCode > 90)&&(charCode < 97 || charCode > 112)&&(charCode !=32)){
//alert("only digit.");
var error = "#lbl-"+$(this).attr('id').split('-')[1];
$(error).html('Only Alphabets values allowed.');
$(this).css('border-color','red' ).css('border-width','2px');
return false;
}else {
var error = "#lbl-"+$(this).attr('id').split('-')[1];
$(error).html('');
$(this).css('border-color','' ).css('border-width','');
return true;
}      
});
});
}
function Validate()
{
var result = true;
$(".require").each(function() {
if($(this).val() === "")
{
$(this).css('border-color','red' ).css('border-width','2px');
var error = "#lbl-"+$(this).attr('id').split('-')[1];
$(error).html($(this).attr('validate'));
result = false;
}
else
{
$(this).css('border-color','' ).css('border-width','');
var error = "#lbl-"+$(this).attr('id').split('-')[1];
$(error).html('');
}
});
$("select").each(function() {
if($(this).val() === "0")
{
$(this).css('border-color','red' ).css('border-width','2px');
var error = "#lbl-"+$(this).attr('id').split('-')[1];
$(error).html($(this).attr('validate'));
result = false;
}
else
{
$(this).css('border-color','' ).css('border-width','');
var error = "#lbl-"+$(this).attr('id').split('-')[1];
$(error).html('');
}
});
return result;
}
$("#submit").click(function() {
if (Validate() === true)
{
return true;
}
else
{
return false;
}
});

});
</script>
 <form  name="form" id="form">
 <center>
 <table >
 </center>
 <tr>
     <td>
Name:
</td>
        <td>
        <input type ="text" class="alphabet require" name="txt1" id ="txt-firstname" validate="Please enter the first name"/>
<label id="lbl-firstname" style="color:red"></label>
</td>
 </tr>
 <tr>
     <td>
Last Name:
</td>
        <td>
        <input type ="text" class="alphabet require" name="txt2" id ="txt-lastname" validate="Please enter the last name"/>
<label id="lbl-lastname" style="color:red"></label>
</td>
 </tr>
  <tr>
     <td>
Address:
</td>
        <td>
        <input type ="text" class="alphabet" name="txt3" id ="txt-address" validate="Please enter the address"/>
<label id="lbl-address" style="color:red"></label>
</td>
 </tr>
   <tr>
     <td>
Mobile:
</td>
        <td>
        <input type ="text" class="numeric" name="txt5" id ="txt-mobile" validate="Please enter the Mobile"/>
<label id="lbl-mobile" style="color:red"></label>
</td>
 </tr>
   <tr>
     <td>
email id:
</td>
        <td>
        <input type ="text" class="alphabet" name="txt4" id ="txt-email" validate="Please enter the email id"/>
<label id="lbl-email" style="color:red"></label>
</td>
 </tr>
 <tr>
     <td>
 State:
</td>
        <td>
         <select id="ddl-state" name="select1" validate="Please select the state">
 <option value="0">--selest--</option>
<option value="Uttar pradesh">Uttar pradesh</option>
<option value="Bihar">Uttar pradesh</option>
</select>
<label id="lbl-state" style="color:red"></label>
</td>
 </tr>
  <tr>
     <td>
 City:
</td>
        <td>
         <select id="ddl-city" name="select2" validate="Please select the city"> 
 <option value="0">--selest--</option>
<option value="Ghaziabad">Uttar pradesh</option>
<option value="Luclnow">Uttar pradesh</option>
</select>
<label id="lbl-city" style="color:red"></label>
</td>
 </tr> 
 <tr>
     <td>
 <input type="submit" id="submit" name="submit" value="Submit" / >
</td>
        <td>
      <input type="reset" id="reset" name="reset" value="Reset" / >   
</td>
 </tr>
 </table>
 </form>

Thursday 11 April 2013

Jquery Datepicker with Age count function



<script type="text/javascript" src="js/jquery-1.7.2.js"></script>
<script type="text/javascript" src="js/jquery.ui.datepicker.js"></script>
<link rel="stylesheet" type="text/css" href="css/ui-lightness/jquery-ui-1.8.23.custom.css" />
<script type="text/javascript" src="js/jquery-ui-1.8.23.custom.min.js"></script>

<script type="text/javascript">
function cal_age() {
var bday=(document.getElementById("dateofbirth").value);
 
var spl =  bday.split("/");
var bdate = spl[0];
var bmonth = spl[1];
var byear = parseInt(spl[2]);
//alert(byear);
//var bmo=(parseInt(document.getElementById("selMonths").value)-1);
//var byr=parseInt(document.getElementById("selYears").value);
var age;
var now = new Date();
tmo=(now.getMonth());
tday=(now.getDate());
//alert(tday);
var tyr=parseInt(now.getFullYear());
{
if(tyr > byear)
{age=byear}
  else
{age=byear}
document.getElementById("txtApAge").value=(tyr-age);
}
}

</script>

<script type="text/javascript">
$(document).ready(function(){
// $("#dateofbirth").datepicker({ 
 //  dateFormat: 'yy-mm-dd',
//   showAnim: 'slideDown',
// changeMonth: true,
// yearRange: '1950:2012',
// changeYear: true }); 
 $('#dateofbirth').datepicker({
changeMonth: true,
showAnim: 'slideDown',
changeYear: true,
maxDate:0,
dateFormat: 'dd/mm/yy',
      yearRange: '1950:+0'});
});
</script>
<style type="text/css"> 
      .ui-datepicker
       {
           font-size: 8pt;
           font-family: Verdana;
       }       
</style>
  <table>
      <tr id="trOdd">
<td width="15%">
<b>Date of Birth :</b><font size="2" color="#FF0000"> </font>
</td>
<td>
 <input type="text" size="20" name="dateofbirth" id="dateofbirth" readonly="readonly" onchange="cal_age();" maxlength="100" ></input>
</td>
<td width="29%"><B>AGE :</B><font size="2" color="#FF0000"> </font>
<input type="text" name="txtApAge" id="txtApAge" size="5" maxlength="4" readonly />&nbsp;&nbsp;<b></b>
  </td>
</tr>
</table>
<a href="http://jqueryui.com/datepicker/" target="_blank">download datepicker Widgets</a>  


Thursday 4 April 2013

SQL Cursor Example


     To use cursors in SQL Server, you need to do the following steps:

-- (1) Declare a cursor that defines a result set.
-- (2) Open the cursor to establish the result set.
-- (3)  Fetch the data into local variables as needed from the cursor.
-- (4) Close the cursor when done.
-- (5) Deallocate the cursor.


declare cr2 cursor for select id from fst 
open cr2
fetch from cr2;
close cr2
deallocate cr2

-----------------------------------------------------------
 ---  Use Cursor on a Table 'fst' to featch 'id' column records

declare cr1 cursor for select id from fst 
declare @id int;
open cr1
fetch from cr1 into @id;
while @@FETCH_STATUS = 0
begin
print @id
fetch from cr1 into @id
end
close cr1
deallocate cr1


Create a Cursor to take Backup and Restore of all SQL Server databases

------ Here is an example of CURSOR to take Backup of all SQL Server databases where backups are issued in a serial manner ------

DECLARE @name VARCHAR(50) -- database name  
DECLARE @path VARCHAR(256) -- path for backup files  
DECLARE @fileName VARCHAR(256) -- filename for backup  
DECLARE @fileDate VARCHAR(20) -- used for file name 

SET @path = 'D:\BackUp\'  

SELECT @fileDate = CONVERT(VARCHAR(20),GETDATE(),112) 

DECLARE db_cursor CURSOR FOR  
SELECT name 
FROM MASTER.dbo.sysdatabases 
WHERE name NOT IN ('master','model','msdb','tempdb')  

OPEN db_cursor   
FETCH NEXT FROM db_cursor INTO @name   

WHILE @@FETCH_STATUS = 0   
BEGIN   
       SET @fileName = @path + @name + '_' + @fileDate + '.BAK'  
       BACKUP DATABASE @name TO DISK = @fileName  

       FETCH NEXT FROM db_cursor INTO @name   
END   

CLOSE db_cursor   
DEALLOCATE db_cursor


----------- Create a CURSOR to Restore  SQL Server Databases ------------


DECLARE @DBName varchar(255)
DECLARE @DATABASES_Fetch int
DECLARE DATABASES_CURSOR CURSOR FOR
Select DATABASE_NAME = name From sys.sysdatabases
where name in ('Testing','amantrn') order by 1
OPEN DATABASES_CURSOR
FETCH NEXT FROM DATABASES_CURSOR INTO @DBName
WHILE @@FETCH_STATUS = 0
BEGIN
exec ('RESTORE DATABASE ' + @DBName + ' FROM DISK =''D:\BackUp\' + @DBName +'.bak'' WITH REPLACE')
FETCH NEXT FROM DATABASES_CURSOR INTO @DBName
END
CLOSE DATABASES_CURSOR
DEALLOCATE DATABASES_CURSOR