Archive for the ‘Java Script’ Category
Fill HTML DropDown Using Javascript
Sunday, October 7th, 2007function FillDropDown()
{
document.frm.dropdown1.innerHTML = “”;
var option1 = document.createElement(‘option’);
option1.appendChild(document.createTextNode(“— Please Select —”));
option1.setAttribute(‘value’, “”);
document.frm.ddType.appendChild(option1);
for(var x = 1; x <= 3; x++)
{
var option = document.createElement(‘option’);
option.appendChild(document.createTextNode(“cat-”+ x));
option.setAttribute(‘value’, x);
document.frm.dropdown1.appendChild(option);
}
}
JavaScript to Check Characters in a String
Friday, October 5th, 2007//The function given below is use to validate the string in correct format or not. In case of correct format the function will return true as result otherwise will return false.
<script language=’javascript’ type=’text/javascript’>
function IsLettersDigitsChars(strString)
{
      var strValidChars = “?0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ,()_&-. \n”;
      var strChar;
      var blnResult = true;
      if (strString.length == 0) return false;
      // test strString consists of valid characters listed above
      for (i = 0; i < strString.length && blnResult == true; i++)
      {
            strChar = strString.charAt(i);
            if (strValidChars.indexOf(strChar) == -1)
            {
                   blnResult = false;
             }
      }
      return blnResult;
}
</script>
JavaScript: To Print the Data of Particular Area
Monday, October 1st, 2007function CallPrint(DivId)
{
 var prtContent = document.getElementById(DivId);
 var WinPrint = window.open(”,”,’left=0,top=0,bottom=0,right=0,width=1003,height=800,toolbar=0,scrollbars=0,status=0′);
WinPrint.document.write(“<STYLE type=text/css media=print>.page {WRITING-MODE: tb-rl; HEIGHT: 80%}</style>”);
WinPrint.document.write(“<link href=StyleSheet.css rel=stylesheet type=text/css />”);
 WinPrint.document.write(prtContent.innerHTML);
 WinPrint.document.close();
 WinPrint.focus();
 WinPrint.print();
 WinPrint.close();
 }
</script>
