Ver Mensaje Individual
  #1 (permalink)  
Antiguo 18/11/2004, 15:17
Dani_PHP
 
Fecha de Ingreso: noviembre-2003
Mensajes: 22
Antigüedad: 20 años, 5 meses
Puntos: 0
campos de texto dinamicos (javascript) insertar sus valores en BD

Buenas mi problema es el siguiente:

Creo dinamicamente varios campos de texto que sirven para rellenarlos con nombres, pues bien ahora quiero que los valores de esos campos de texto introducirlos en una Base de Datos. Osea que quisera recoger los valores de los campos de texto dinamicos en la siguiente pagina...

alguien sabe como??? estoy muuu desesperao!!!

EL CODIGO DE LA PAGINA DEL FORMULARIO ES:

<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<link href="estilo.css" rel="stylesheet" type="text/css">
<SCRIPT language=JavaScript>
// 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;
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 += '<b>Componente ' + tFormFieldCount + '</b>- Nombre del componente&nbsp;&nbsp;<input type="text" name="componente' + tFormFieldCount + ' value="componente' + tFormFieldCount + '"><br>';
document.getElementById('DynamicContent').innerHTM L += '<b>Instrumento ' + tFormFieldCount + '</b>- Instrumentos que toca&nbsp;&nbsp;&nbsp;&nbsp;<input type="text" name="instrumento' + tFormFieldCount + ' value="instrumento' + tFormFieldCount + '"><br>';
} /*else if (FieldType == 'Textarea') {
document.getElementById('DynamicContent').innerHTM L += 'Form Element ' + tFormFieldCount + '- Textarea&nbsp;&nbsp;<textarea name="Textarea' + tFormFieldCount + '" cols=30 rows=3></textarea><br>';
}*/

// 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 validar(form)
{
if (tFormFieldCount == 1) {
alert('Has de poner como minimo 1 componente!!!');
return false;
}
if (form.nombre.value=="")
{
alert("Ha de poner un nombre válido.");
form.nombre.focus();
return (false);
}

if (form.estilo.value=="1")
{
alert("Has de poner un estilo que se acerque al vuestro.");
form.estilo.focus();
return (false);
}

if (form.procedencia.value=="")
{
alert("El campo procendencia se encuentra vacío.");
form.procedencia.focus();
return (false);
}

if (form.texto.value=="")
{
alert("No teneis biografia?, has de poner algo en el campo.");
form.texto.focus();
return (false);
}

if (form.contacto.value=="")
{
alert("Inserta algun email de contacto o telefono.");
form.contacto.focus();
return (false);
}
return (true);
}
</script>
</head>

<body bgcolor="#FFFFCC" link="#990000" vlink="#990033" alink="#996633">
<div align="center"><img src="../img/callesonora.jpg" width="500" height="81">
</div>
<p align="center">&nbsp;</p>
<p><strong>Insertar grupo musical en la base de datos de www.callesonora.com:</strong></p>
<form name="form" method="post" action="insertgrupo.php" onSubmit="return validar(this)">
<table width="80%" border="0">
<tr>
<td>Nombre:</td>
<td colspan="2"><input name="nombre" type="text" id="nombre" size="50"></td>
</tr>
<tr>
<td>Estilo:</td>
<td colspan="2"><select name="estilo" id="estilo">
<option value="1">-ELIGE UNA OPCI&Oacute;N-</option>
<option value="Rock">Rock</option>
<option value="Mestizaje">Mestizaje</option>
<option value="Punk-rock">Punk-rock</option>
<option value="Punk">Punk</option>
<option value="Hip hop">Hip hop</option>
<option value="Ragga">Ragga</option>
<option value="Reggae">Reggae</option>
<option value="Heavy">Heavy</option>
<option value="Metal">Metal</option>
<option value="New Metal">New Metal</option>
<option value="Folk">Folk</option>
<option value="Cantautor">Cantautor</option>
<option value="Flamenco">Flamenco</option>
<option value="Ska">Ska</option>
<option value="Hardcore">Hardcore</option>
<option value="Rumba">Rumba</option>
</select></td>
</tr>
<tr>
<td>MP3:</td>
<td colspan="2"><input name="mp3" type="checkbox" id="mp3" value="si">
(marcar si teneis mp3 en la web)</td>
</tr>
<tr>
<td>Web:</td>
<td colspan="2"><input name="web" type="text" id="web" size="50"></td>
</tr>
<tr>
<td width="10%">Procedencia:</td>
<td colspan="2"><input name="procedencia" type="text" id="procedencia" size="50">
</td>
</tr>
<tr>
<td>Biografia:</td>
<td colspan="2"><textarea name="texto" cols="90" rows="15" id="texto"></textarea></td>
</tr>
<tr>
<td>Contacto:</td>
<td colspan="2"><input name="contacto" type="text" id="contacto" size="50">
(email de contacto)</td>
</tr>
<tr>
<td>Comentario:</td>
<td colspan="2"><textarea name="comentario" cols="90" id="comentario"></textarea></td>
</tr>
<tr>
<td>&nbsp;</td>
<td colspan="2">&nbsp;</td>
</tr>
<tr>
<td>&nbsp;</td>
<td colspan="2">
<table cellspacing=0 cellpadding=4 border=0>
<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> <input name="button" type="button" onClick="MakeOne('TextInput');" value="A&ntilde;adir componente">
<!-- 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">
</td>
</tr>
</table>
</td>
</tr>
<tr>
<td>&nbsp;</td>
<td width="16%"><input name="enviar" type="submit" id="enviar" value="Enviar"></td>
<td width="74%"><input type="reset" name="Submit2" value="Borrar"></td>



GRACIAS POR TODO!!!

Última edición por Dani_PHP; 18/11/2004 a las 15:20