<html>
<head>
<script type=”text/javascript”>
var shiftOn = false;
var ctrlOn = false;
var altOn = false;
var focusedValue = “0″;
function validateNumeric(obj)
{
if (obj.value.length == 0)
{
obj.value = focusedValue;
return false;
}
[...]
Read Full Post »
<html>
<head>
<title>Demo</title>
<script type=”text/javascript”>
function textChanged(elm)
{
alert(elm.value);
}
onload = function()
{
var elm = document.getElementById(”mytextbox”);
elm.onchange = new Function(’textChanged(this)’);
[...]
Read Full Post »
<input type=”text” id=”mytb” />
To select: document.getElementById(”mytb”).select()
To unselect: document.getElementById(”mytb”).value = document.getElementById(”mytb”).value;
Just the value to itself. That’s all!
Read Full Post »
Posted in DHTML, HTML, JavaScript on February 12, 2008 | No Comments »
<html><head>
<script type=”text/javascript”>
img2=new Image();img2.src=“landscape3.gif”;
function changeImage(){
document.getElementById(‘myImage’).src=img2.src;}
</script></head><body>
<p>
When you mouse over the image, a new image will appear.</p>
<img id=”myImage” onmouseover=”changeImage()” border=”0″ width=”160″ height=”120″
src=”landscape2.jpg”>
<p>
The new image appears instantly, because your browser has already loaded the image.</p></body></html>
Read Full Post »
Posted in JavaScript, Uncategorized on February 12, 2008 | No Comments »
<%@ Page Language=”C#” AutoEventWireup=”true” CodeFile=”Default.aspx.cs” Inherits=”_Default” %>
<!DOCTYPE html PUBLIC “-//W3C//DTD XHTML 1.0 Transitional//EN” “http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd”><html xmlns=”http://www.w3.org/1999/xhtml”><head runat=”server”>
<title>Untitled Page</title></head><body>
<form id=”form1″ runat=”server”>
<div>
<script type=”text/javascript”>
var BrowserDetect = {init: function () {
this.browser = this.searchString(this.dataBrowser) || “An unknown browser”;this.version = this.searchVersion(navigator.userAgent)||
this.searchVersion(navigator.appVersion)|| “an unknown version”;
this.OS = this.searchString(this.dataOS) || “an unknown OS”;},
searchString: function (data) {for (var i=0;i<data.length;i++) {
var dataString = data[i].string;var dataProp = [...]
Read Full Post »
<%@ Page Language=”C#” AutoEventWireup=”true” CodeFile=”Default.aspx.cs” Inherits=”_Default” %>
<!DOCTYPE html PUBLIC “-//W3C//DTD XHTML 1.0 Transitional//EN” “http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd”>
<html xmlns=”http://www.w3.org/1999/xhtml”>
<head runat=”server”>
<title>Untitled Page</title>
</head>
<body>
<form id=”form1″ runat=”server”>
<div>
<asp:ListBox ID=”LBSource” SelectionMode=”Multiple” runat=”server”>
<asp:ListItem Text=”Item1″ Value=”vItem1″></asp:ListItem>
<asp:ListItem Text=”Item2″ Value=”vItem2″></asp:ListItem>
<asp:ListItem Text=”Item3″ Value=”vItem3″></asp:ListItem>
<asp:ListItem Text=”Item4″ Value=”vItem4″></asp:ListItem>
<asp:ListItem Text=”Item5″ Value=”vItem5″></asp:ListItem>
</asp:ListBox>
<input type=”button” value=”Add” onclick=”moveItems(’<%= LBSource.ClientID %>‘, ‘<%= LBDestination.ClientID %>‘)” />
<input type=”button” value=”Remove” onclick=”moveItems(’<%= LBDestination.ClientID %>‘, ‘<%= LBSource.ClientID %>‘)” />
<asp:ListBox [...]
Read Full Post »
Posted in JavaScript, Uncategorized on September 29, 2006 | No Comments »
This is a cool script that gives the same effect as the C# string formating with multiple parameters. Check it out:
function format(str)
{
for(i = 1; i < arguments.length; i++)
{
str = str.replace(’{’ + (i - 1) + ‘}’, arguments[i]);
}
return str;
}
Example: <font color=”#008000″>greeting = format(’Hello {0} & {1} ‘, ‘John’, ‘Jane’);</font>
Read Full Post »