Last active
March 14, 2019 15:24
-
-
Save daniiable/ae7b6e7624ab97ee819a3af05381b741 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!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> | |
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> | |
<title>Documento sin título</title> | |
<link href="http://yui.yahooapis.com/pure/0.6.0/pure-min.css" rel="stylesheet" type="text/css" /> | |
</head> | |
<body> | |
<script> | |
function myCreateFunction() { | |
var table = document.getElementById("myTable"); | |
var row = table.insertRow(0); | |
var fila = table.insertRow(); | |
var cell1 = row.insertCell(0); | |
var cell2 = row.insertCell(1); | |
// CREO UN ELEMENTO DEL TIPO INPUT CON document.createElement("NOMBRE TAG HTML QUE QUIERO CREAR"); | |
var input = document.createElement("input"); | |
input.type = "text"; | |
input.className = "urlresp"; | |
input.value = "Url respuesta"; | |
input.setAttribute("onclick", "vaciar_campo(this);"); | |
input.style.height = "20px"; | |
input.style.width = "100px"; | |
// Creo un segundo elemento Input | |
var input2 = document.createElement("input"); | |
input2.type = "text"; | |
input2.className = "ptss"; | |
input2.value = "0"; | |
input2.setAttribute("onclick", "vaciar_campo(this);"); | |
input2.style.height = "20px"; | |
input2.style.width = "30px"; | |
var campo4 = document.createElement("input"); | |
campo4.type = "button"; | |
campo4.value = "-"; | |
campo4.onclick = function () | |
{ | |
var fila = this.parentNode.parentNode; | |
var tbody = table.getElementsByTagName("tbody")[0]; | |
tbody.removeChild(fila); | |
} | |
// CON EL METODO appendChild(); LOS AGREGO A LA CELDA QUE QUIERO | |
cell1.appendChild(input); | |
cell2.appendChild(input2); | |
cell2.appendChild(campo4); | |
} | |
function vaciar_campo(input) { | |
input.value = ""; | |
} | |
</script> | |
<button onclick="myCreateFunction()" type="button"> | |
<img src="Boton1.png"> | |
</button> | |
<br> | |
<table id="myTable" border="0"> | |
<tr> | |
<input name="urlresp" type="text" id="urlresp" style="height: 20px; width: 100px;" onFocus="vaciar_campo(this)" value="Url respuesta"> | |
<input name="ptss" type="text" class="ptss" id="ptss" style="height: 20px; width: 30px;" onFocus="vaciar_campo(this)" value="0"> | |
</tr> | |
</table> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment