Can´t process variables from java interactive forms with php
Posted: Fri Nov 05, 2004 11:20 am
I have a form which is used to insert thing to a mysql database... Some items are fixed, like name and address but other, like telephone numbers and e-mails can be none, one or more so I make an add button to allow to insert input fields in a "span position:relative". It works ok but when I submit the form i can't get those inputs (i.e. $_POST["telefono1"] isn´t set when it should be)
.
Here I send you some code, first of all the javascript function:
Note : ELSE is not working 'couse number parameter is always 1.
Note 2: menuCaracTel() is a PHP functions that makes a dropdown menu with telephone prefixes. Also, names are in spanish.
After submit PHP should insert phones in tables here:
'While' is obbvied 'couse no telephone variable is set, the normal inputs of the form are inserted in others table with no problem...
I wish you can help me, I think the problem is that the inputs are seen but not passed through $_POST data, probably I should make this in another way, don´t know. Thank you very much.
YESS!! you´ll help will be VERY appreciated... 
Here I send you some code, first of all the javascript function:
Code: Select all
function addTel(number) {
totaltel = totaltel + number;
telfield = "";
if (number < 16 && number > -1) {
for (i=1; i <= number; i++) {
if (totaltel > 1) {telfield = telfield + "<br>"; }
telfield += "(" + "<? echo menuCaracTel("+ totaltel +",1); ?>" + ")";
telfield += "&nbsp;<input type='text' size='30' maxlength='70' name='telefono" + totaltel + "'>";
}
if (document.layers) {
document.layers.fieldtel.document.write(telfield);
document.layers.fieldtel.document.close();
}
else {
if (document.all) {
fieldtel.innerHTML += telfield;
}
}
}
else {
window.alert("Please select up to 15 entries.");
}
}Note 2: menuCaracTel() is a PHP functions that makes a dropdown menu with telephone prefixes. Also, names are in spanish.
After submit PHP should insert phones in tables here:
Code: Select all
$numtel = 1;
$tel = 'telefono'.$numtel;
while (isset($_POST[$tel])) {
$IDtelefono = nuevoId("IDtelefono","telefonos");
$tipo = 'T';
$carac = 'caractel'.$numtel;
$caracteristica = $_POST[$carac];
$numero = $_POST[$tel];
$descripcion = '';
$sql3 = "INSERT INTO telefonos VALUES ($IDtelefono,'$tipo',$caracteristica,$numero,$descripcion)";
mysql_query($sql3);
$sql4 = "INSERT INTO lista-telefonos VALUES ($IDcentro,$IDtelefono)";
mysql_query($sql4);
$numtel++;
$tel = 'telefono'.$numtel;
}I wish you can help me, I think the problem is that the inputs are seen but not passed through $_POST data, probably I should make this in another way, don´t know. Thank you very much.