Monday, February 23, 2009

JAVA SCRIPT Code Samples

Question:-Some javasciprt good option?
(1) How to disable right click option body oncontextmenu="return false;"

(2)How to use Ltrim In Javascirpt?
var strTemp = " Left padded string";
alert(strTemp);
strTemp = LTrim(strTemp);
alert(strTemp);

(3)How to get A ASCII Value of ANy character ?
alert(Asc("a"));
alert(Asc("B"));

(4)Get Back Character to ASCII
alert(Chr(80));
alert(Chr(82));

(5)Use of CBool funation in javascript
var StringOne = "No";
if(CBool(StringOne))
{
alert("StringOne evaluates to true");
}
else
{
alert("StringOne evaluates to false");
}

(6)How to Add to integer in JAVSCRIPT ?
var One = CInt("17");
var two = CInt("35");
alert(One + Two);

(7)Concat two string
var One = CStr(1267);
var Two = CStr(3456);
alert(One + Two);

(8)How to add long Value in Javscript ?
var One = CSng("1267.45");
var Two = CSng("3456.67");
alert(One + Two);

(9)Get format acording to exponnet
var tal = 34.5562
alert(FormatCurrency(tal));
alert(FormatCurrency(1000));

(10)Number in the Format of Percent ?
var TheNumber = .15
alert(FormatPercent(TheNumber));

(11)How to get date in specific format ?
var date = "23/07/1983";
alert(date);
date = FormatDate(date,"mmmm/dd/yyyy")
alert(date);

(12)how to get Date ClientSide
var Date = GetDate("dd/mmmm/yyyy");
alert(Date);

(13)How to get Specific String in specific String
var StringOne = "here u can do this due to error Gitesh said ";
if(InStr(StringOne,"gitesh") > -1)
{
alert("Gites found in string");
alert("Term appears at character " + InStr(StringOne,"Gitesh"));
}

(14)How to check value is null or not ?
var EmptyVariable;
if(IsNull(EmptyVariable))
{
alert("Null value detected");
}

(15)How to check numeric value ?
var myVariable = "www.Dotnetquestion.info";
if(IsNumeric(myVariable))
{
alert("Numeric Value detected");
}

(16)how to join Array ?
var var = "dot,net ,question ";
var arr = Var.split(",");
var strTemp = Join(arr," - ");
alert(strTemp);

(17)Convert String in to Lower case ?
var strTemp = LCase("DOTNETQUESTION");
alert(strTemp);

(18)How to get first three Character of string ?
var str = "Dot Net Question";
Leftstr = Left(str,3);
alert(Leftstr);

(19)How to get a length of string ?
var i = Len("www.Dotnetquestion.info");
alert(i);

(20)How to get a substring from string ?
var Temp = "dot net programmer in dotnetquestion.info";
Temp = Mid(Temp,3,3);
alert(Temp);

(21)How to Get string in Proper Case ?
var temp = "gitesh chawla";
temp = PCase(temp);
alert(temp);

(22)Replace a string with another ?
var str = "www.dotnetquestion.com";
str = Replace(str,"com", "info");
alert(str);

(23)How to get string from right of string ?
var strTemp = "Here is javascript in dotnetquestion site";
strTemp = Right(strTemp,4);
alert(strTemp);

(24)Math function
var root = 4;
root = Sqr(root);
alert(root);

(25)How to match two string ?
var str1 = "dot net question"
var str2 = "DOT NET QUESTION"
if(strComp(str1,str2,1))
{
alert("Strings Match");
}

(26)Use of Intellisense Title Case ?
var str1 = "all about the dot net question";
str1 = TitleCase(str1);
alert(str1);

(27)How to get Number of Element in array ?
var strTemp = "dot ,net,question";
var arrTemp = strTemp.split(",");
alert("Array contains " + UBound(arrTemp) + " elements");

(28)How to get string in Upper Case ?
var str = "dot net question";
str = UCase(str);
alert(str);

1 comment:

abselongahr said...

How to play Slots with Real Money
Slots for Real Money. 1. Pick a slot machine of your choice, and if there are a lot of 바카라 필승법 free spin games, you will receive sss 포커 a lot of free spins 블랙잭애니 as 룰렛 이벤트 you play them. 2. Practice 토토 분석 사이트