Foros del Web » Programando para Internet » Javascript »

Elementos dinamicos con Javascript

Estas en el tema de Elementos dinamicos con Javascript en el foro de Javascript en Foros del Web. les cuento. encontre una funncion que me permite generar objetos a traves de javascript, en parte la he adaptado a mis necesidades, haciendo que aparescan ...
  #1 (permalink)  
Antiguo 07/04/2009, 10:31
 
Fecha de Ingreso: abril-2009
Mensajes: 2
Antigüedad: 15 años
Puntos: 0
Elementos dinamicos con Javascript

les cuento. encontre una funncion que me permite generar objetos a traves de javascript, en parte la he adaptado a mis necesidades, haciendo que aparescan los campos (Mantencion para cibercafe) hora inicio, hora termino, tiempo navegado, y total a pagar, el asunto es que cuando presiono el boton iniciar (llama a una funcion "hora()", que me muestra la hora de inicio en el correspondiente campo de texto, no hay problema hasta aqui), pero cuando agrego un nuevo pc, doy inicio nuevamente, pero me aparece esto:

el objeto no soporta esta propiedad o metodo.
a que puede deberse esto? hay solucion para esto?

esto es aparte, las idea mia es primero que todo, que funciones los cronometros y otras cosas, para luego mediante una consulta me rescate el numero de pcs que tengo en la base de datos, y segun el numero de pcs, me muestre los objetos correspondientes, no se si se pueda, investigare!

de antemano, gracias po la ayuda!!!

adjunto el codigo:
-------------------------------------------------------------------------------------------------

<html>
<head>
<title>Form Page</title>
<!-- Javascript code for the dynamic form elements. -->
<script>
// Declare the form field count javascript variable so you know how many the user have added.
//The CGI.REQUEST_METHOD bit is the CF code for setting this variable back to the count where it was last up to.
var tFormFieldCount = 1; //numero de elementos que van apareciendo
var tFormFieldList = "";

// Function to dynamically insert the form field to the cell below. If you want textareas or other form elements, just create another function and change the html insert text below.
function MakeOne(FieldType) {
// Depending on what type of form fields the user choose then dynamically write the appropriate form element to the page
if (FieldType == 'TextInput')
{
document.getElementById('DynamicContent').innerHTM L += 'Form Element ' + tFormFieldCount + '- Text input box&nbsp;&nbsp;<input type="text" name="TextInput' + tFormFieldCount + '"><br>';
}
else if (FieldType == '2')
{
//document.getElementById('DynamicContent').innerHTM L += 'Form Element ' + tFormFieldCount + '- Textarea&nbsp;&nbsp;<textarea name="Textarea' + tFormFieldCount + '" cols=30 rows=3></textarea><br>';

document.getElementById('DynamicContent').innerHTM L += '<b>PC Numero</b>' + tFormFieldCount + ' <TABLE border="1"> <TR> <TD rowspan="4"><img src="pc.png" id="pc"></TD> <TD><input type="button" value="Iniciar" onclick="hora()"></TD> <TD><input type="text" name="h_inicio"></TD> </TR> <TR> <TD><input type="button" value="Terminar"></TD> <TD><input type="text" name="h_termino"></TD> <TD></TD> </TR> <TR> <TD>Tiempo Navegado</TD> <TD><input type="text" name="t_navegado"></TD> <TD></TD> </TR> <TR> <TD>Total a Pagar</TD> <TD><input type="text" name="pagar"></TD> <TD></TD> </TR> </TABLE>';

}

// Populate the form element list.
if (tFormFieldList == "") {
tFormFieldList = FieldType;
} else {
tFormFieldList += "," + FieldType;
}

document.forms[0].FormFieldCount.value = tFormFieldCount;
document.forms[0].FormFieldList.value = tFormFieldList;
tFormFieldCount++;
}

// Just a function to check if the user have added any text input fields.
function CheckIt() {
if (tFormFieldCount == 1) {
alert('You must add at least one text input field.');
return false;
}
return true;
}
function hora() // muestra la hora de inicio en el campo de texto Hora de Inicio del movimiento
{
momentoActual = new Date();
hora = momentoActual.getHours();
minuto = momentoActual.getMinutes();
segundo = momentoActual.getSeconds();
document.formulario.h_inicio.value = hora + ":" + minuto + ":" + segundo;
//document.formulario.tfinal.value="";
//document.formulario.navegado.value="";
}
</script>
</head>

<body bgcolor="#FFFFFF">
<!-- HTML form tag. -->
<!-- Action attribute specify where the form data is to be sent to -->
<!-- Method attribute specify what method the form data is to be sent. POST or GET. Default is GET. -->
<form name="formulario">
<table cellspacing=0 cellpadding=4 border=1>
<!-- <input type="button" value="Add Form Text Fields" onClick="MakeOne('TextInput');"> -->
<tr><td align="right">&nbsp;&nbsp;<input type="button" value="Agregar pc" onClick="MakeOne('2');"></td></tr>
<tr>
<td id="DynamicContent" valign="top">
<!-- Cold fusion code again to test to see if the request method of this page is POST or GET. -->
<!-- If is POST then you know is from the result page and there's data to be output. -->

</td>
</tr>
<tr>
<td align="right" colspan=2>
<!-- Hidden form field to pass the count of the text inputs to the result page. -->
<input type="hidden" name="FormFieldList">
<input type="hidden" name="FormFieldCount">
<!--<input type="submit" value="Send It"> -->
</td>
</tr>
</table>
</form>
</body>
</html>

--------------------------------------------------------------------------------------
Atención: Estás leyendo un tema que no tiene actividad desde hace más de 6 MESES, te recomendamos abrir un Nuevo tema en lugar de responder al actual.
Respuesta




La zona horaria es GMT -6. Ahora son las 13:40.