More Games - PAINONE

Android games

sites.google.com


get id : ".$_GET[id]."

"; echo "

get passwd : ".$_GET[passwd]."

"; echo "

post id : ".$_POST[id]."

"; echo "

post passwd : ".$_POST[passwd]."

"; ?>

'Language > Ajax' 카테고리의 다른 글

Ajax 간단한 예제소스  (0) 2010.05.23
 

More Games - PAINONE

Android games

sites.google.com

 

More Games - PAINONE

Android games

sites.google.com

	var request = null;
	function createRequest() {
		try {
			request = new XMLHttpRequest();
		} catch (trymicrosoft) {
			try {
				request = new ActiveXObject("Msxml2.XMLHTTP");
			} catch (othermicrosoft) {
				try {
					request = new ActiveXObject("Microsoft.XMLHTTP");
				} catch (failed) {
					request = null;
				}
			}
		}

		if (request == null) {
			alert("너가 사용하는 브라우저는 도대체 뭐냐..??");
		}
	}

	function getBoardsSold() {
		createRequest()
		var content = document.getElementById("content");
		var contentStr = getText(content);
		var url = "test.php?ContentStr=" + contentStr;

		request.open("GET", url, true);
		request.onreadystatechange = updatePage;
		request.send(null);
	}

	function updatePage() {
		if (request.readyState == 4) {
			if(request.status == 200) {
				var newContent = request.responseText;
				var contenttStr = document.getElementById("Content");
				replaceText(contentStr, newContent);
			} else {
				alert("서버에러!!");
			}
		}
	}

	function replaceText(el, text) {
		if (el != null)	{
			clearText(el);
			var newNode = document.createTextNode(text);
			el.appendChild(newNode);
		}
	}

	function clearText(el) {
		if (el != null) {
			if (el.childNodes) {
				for (var i = 0; i < el.childNodes.length; i++) {
					var childNode = el.childNodes[i];
					el.removeChild(childNode);
				}
			}
		}
	}

	function getText(el) {
		var text = "";
		if (el != null) {
			if (el.childNodes) {
				for (var i = 0; i < el.childNodes.length; i++) {
					var childNode = el.childNodes[i];
					if (childNode.nodeValue != null) {
						text = text + childNode.nodeValue;
					}
				}
			}
		}
		return text;
	}

'Language > Ajax' 카테고리의 다른 글

GET방식 POST방식  (0) 2010.05.23
 

More Games - PAINONE

Android games

sites.google.com

 

More Games - PAINONE

Android games

sites.google.com

일반적인 사용예)
function AddEvent() {
	var div = document.getElementById("div");
	if(div.addEventListener) {
		div.addEventListener("click", test, false);	// IE 외 타 브라우저
	} else {
		div.attachEvent("onclick", test);			// IE
	}
}
	
function test() {
	var a = 1;
	var b = 2;
	alert(a + b);
}
인자 넘기기 예)
function AddEvent(a, b) {
	var div = document.getElementById("div");
	if(div.addEventListener) {
		div.addEventListener("click", function(a, b) { test(a, b); }, false);
	} else {
		div.attachEvent("onclick", function(a, b) { test(a, b); });
	}
}
	
function test(a, b) {
	alert(a + b);
}
 

More Games - PAINONE

Android games

sites.google.com

 

More Games - PAINONE

Android games

sites.google.com

	var CreatePalette = function(color) {
		var div	= document.getElementById("colorTable");
			div.innerHTML = ""; 
		var r	= parseInt(color.replace("#","").substring(0,2), 16);
		var b	= parseInt(color.replace("#","").substring(2,4), 16);
		var g	= parseInt(color.replace("#","").substring(4,6), 16);
		var colorDiv;
		for(var i = 0; i < 26; i++) {
			colorDiv						= document.createElement("div");
			colorDiv.style.backgroundColor	= color;
			colorDiv.style.padding			= "2px";
			colorDiv.style.fontFamily		= "돋움, dotum, verdana";
			colorDiv.innerText				= color.toUpperCase();
			div.appendChild(colorDiv);

			r = (r + 10 < 255) ? r + 10 : r;
			b = (b + 10 < 255) ? b + 10 : b;
			g = (g + 10 < 255) ? g + 10 : g;
			red		= (r.toString(16).length <= 1) ? "0" + r.toString(16) : r.toString(16);
			blue	= (b.toString(16).length <= 1) ? "0" + b.toString(16) : b.toString(16);
			green	= (g.toString(16).length <= 1) ? "0" + g.toString(16) : g.toString(16);
			
			if(color == "#" + red + blue + green) {
				return false;
			} else {
				color = "#" + red + blue + green;
			}
		}
	}
 

More Games - PAINONE

Android games

sites.google.com

 

More Games - PAINONE

Android games

sites.google.com

	/**
	*	배열에 지정값을 가장 마지막으로 옮기기
	*	사용 예)
	*	var arr = new Array();
	*		arr[0] = "a";
	*		arr[1] = "b";
	*		arr[2] = "c";
	*		arr[3] = "d";
	*
	*	arr = ArrayValSort(arr, "a");
	*	for(key in arr) {
	*		document.write("

" + key + " = " + arr[key] + "

"); * } * 출력) * 0 = b * 1 = c * 2 = d * 3 = a */ function ArrayValSort(sortArray, val) { var valArr = []; var newArr = []; for(k in sortArray) { if(sortArray.hasOwnProperty) { if(sortArray[k] != val) { valArr.push(sortArray[k]); } } } for(var i = 0; i < valArr.length; i++) { newArr.push(valArr[i]); } newArr.push(val); return newArr; }
 

More Games - PAINONE

Android games

sites.google.com

+ Recent posts