function CompareDate()
{
var Date1 = document.getElementById('uxDate');
var SplitDate1 = Date1.value.split("/");
var dd1=SplitDate1[1];
var mm1=SplitDate1[0];
var yy1=SplitDate1[2];
var startDate = new Date(yy1,mm1-1,dd1);
var endDate = new Date();
if(startDate >= endDate)
{
alert("Start date should not greater then end date");
return false;
}
else
{
return true;
}
}
Friday, September 30, 2011
Simple javascript to compare date
Create XML file in javascript from Gridview
Please find below JS for creating xml file from grid using javascript
function CreateXMLFromGrid()
{
var gvControl = document.getElementById('<%= grid1.ClientID %>');
var gvControlID = '<%= grid1.ClientID %>';
// hidden id so xml is stored here
var uxhdnXML = document.getElementById('<%= uxhdnXML.ClientID %>');
var strOut;
strOut = ""; ";
for (i = 0; i <= gvControl.rows.length - 2; i = i + 1)
{
// will set grid row index
if (parseInt(i + 2) <= 9)
midfix = '0' + parseInt(i + 2);
else
midfix = parseInt(i + 2);
// text box control in grid
var txtbox = document.getElementById(gvControlID + '_ctl' + midfix + '_txt1');
// Drop down list control in grid
var ddllist = document.getElementById(gvControlID + '_ctl' + midfix + '_ddl1');
// Radio button list control in grid
var rblist = document.getElementById(gvControlID + '_ctl' + midfix + '_rdl1');
var resvalue = null;
if (txtbox != null)
{
resvalue = txtbox.value;
if (resvalue == "")
{
resvalue = "NULL";
}
}
if (ddllist != null)
{
resvalue = ddllist.value
if (resvalue == "")
{
resvalue = "NULL";
}
}
if (rblist != null)
{
// below will check from dropdown list weather radio button is checked or not
var checkBoxArray = rblist.getElementsByTagName("input");
for (var j = 0; j < checkBoxArray.length; j++)
{
if (document.getElementById(gvControlID + '_ctl' + midfix + '_rdlSetupvalue' + '_' + j.toString()).checked == true)
{
var checkBoxRef = checkBoxArray[j];
var labelArray = checkBoxRef.parentNode.getElementsByTagName("label");
resvalue = labelArray[0].innerHTML;
break;
}
}
if (resvalue == "")
{
resvalue = "NULL";
}
}
strOut = strOut + ""; ";
strOut = strOut + "" + resvalue + " ";
strOut = strOut + "
}
strOut = strOut + "
// assign created xml to hidden value
uxhdnXML.value = strOut;
}
Subscribe to:
Posts (Atom)