All pastes #909882 Raw Edit

Miscellany

public text v1 · immutable
·published 2008-02-19 16:24 UTC
rendered paste body
function createTextInput (_value, _width, _inputid, _tableid, _where) {
	var _value2 = _value;

	var is_table = 0;
	var is_input = 0;

	var textInputTable = document.createElement("table");
	
	var textInputTr1 = document.createElement("tr");
		var textInputTr1Td1 = document.createElement("td");
		var textInputTr1Td2 = document.createElement("td");
		var textInputTr1Td3 = document.createElement("td");

	var textInputTr2 = document.createElement("tr");
		var textInputTr2Td1 = document.createElement("td");
		var textInputTr2Td2 = document.createElement("td");
		var textInputTr2Td3 = document.createElement("td");

	var textInputTr3 = document.createElement("tr");
		var textInputTr3Td1 = document.createElement("td");
		var textInputTr3Td2 = document.createElement("td");
		var textInputTr3Td3 = document.createElement("td");

	var textForm = document.createElement("form");
	var textInput = document.createElement("input");

	var lws = document.createTextNode("What you are typing now: "+_value);

	textForm.appendChild(textInput);
	textInputTr2Td2.appendChild(textForm);
	textInputTr2Td2.appendChild(lws);

	textInput.type = "text";
	textInput.value = _value;
	if ( _width != "" ) {
		textInput.style.width = _width;
		textInputTr2Td2.style.width = _width;
	}
	if ( _inputid != "" )
		textInput.id = _inputid;

	textInputTr1.appendChild(textInputTr1Td1);
	textInputTr1.appendChild(textInputTr1Td2);
	textInputTr1.appendChild(textInputTr1Td3);

	textInputTr2.appendChild(textInputTr2Td1);
	textInputTr2.appendChild(textInputTr2Td2);
	textInputTr2.appendChild(textInputTr2Td3);

	textInputTr3.appendChild(textInputTr3Td1);
	textInputTr3.appendChild(textInputTr3Td2);
	textInputTr3.appendChild(textInputTr3Td3);

	textInputTable.appendChild(textInputTr1);
	textInputTable.appendChild(textInputTr2);
	textInputTable.appendChild(textInputTr3);

	document.getElementById(_where).appendChild(textInputTable);

	textInput.onchange = function () {
		textInputTr2Td2.removeChild(lws);
		_value2 = textInput.value;
		lws = document.createTextNode("What you are typing now: "+_value2);
		textInputTr2Td2.appendChild(lws);
	}

	textInput.onmouseover = function () {
		if (is_table == 0 && is_input == 0) {
			textInputTr1Td1.className += "_hover";
			textInputTr1Td2.className += "_hover";
			textInputTr1Td3.className += "_hover";
		
			textInputTr2Td1.className += "_hover";
			textInputTr2Td3.className += "_hover";

			textInputTr3Td1.className += "_hover";
			textInputTr3Td2.className += "_hover";
			textInputTr3Td3.className += "_hover";

			is_input = 1;
		}
	}	

	textInput.onmouseout = function () {
		if (is_input == 1) {
			textInputTr1Td1.className = "text_upper_left";
			textInputTr1Td2.className = "text_top";
			textInputTr1Td3.className = "text_upper_right";

			textInputTr2Td1.className = "text_left";
			textInputTr2Td2.className = "text_cnt";
			textInputTr2Td3.className = "text_right";

			textInputTr3Td1.className = "text_lower_left";
			textInputTr3Td2.className = "text_bottom";
			textInputTr3Td3.className = "text_lower_right";

			is_input = 0;
		}
	}

	textInputTable.onmouseover = function () {
		if (is_table == 0 && is_input == 0) {
			textInputTr1Td1.className += "_hover";
			textInputTr1Td2.className += "_hover";
			textInputTr1Td3.className += "_hover";
		
			textInputTr2Td1.className += "_hover";
			textInputTr2Td3.className += "_hover";

			textInputTr3Td1.className += "_hover";
			textInputTr3Td2.className += "_hover";
			textInputTr3Td3.className += "_hover";

			is_table = 1;
		}
	}

	textInputTable.onmouseout = function () {
		if (is_table == 1) {
			textInputTr1Td1.className = "text_upper_left";
			textInputTr1Td2.className = "text_top";
			textInputTr1Td3.className = "text_upper_right";

			textInputTr2Td1.className = "text_left";
			textInputTr2Td2.className = "text_cnt";
			textInputTr2Td3.className = "text_right";

			textInputTr3Td1.className = "text_lower_left";
			textInputTr3Td2.className = "text_bottom";
			textInputTr3Td3.className = "text_lower_right";

			is_table = 0;
		}
	}

	if ( _tableid != "" )
		textInputTable.id = _tableid;

	textInputTable.className = "text_tbl";

	textInputTr1Td1.className = "text_upper_left";
	textInputTr1Td2.className = "text_top";
	textInputTr1Td3.className = "text_upper_right";

	textInputTr2Td1.className = "text_left";
	textInputTr2Td2.className = "text_cnt";
	textInputTr2Td3.className = "text_right";

	textInputTr3Td1.className = "text_lower_left";
	textInputTr3Td2.className = "text_bottom";
	textInputTr3Td3.className = "text_lower_right";
}