Ver Mensaje Individual
  #9 (permalink)  
Antiguo 20/09/2005, 07:45
Avatar de Vaalegk
Vaalegk
 
Fecha de Ingreso: abril-2005
Mensajes: 154
Antigüedad: 19 años
Puntos: 2
Bueno solo modifique un poco lo que posteaste checkealo, la parte que mas te interesa esta al final el php bastante corto pero demestra el concepto.

Código PHP:
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<script language="javascript">

data="<input type='text' name='answers[]' id='answers' class='txtBoxStyle3' size='38'><a hre='#' onClick='DeleteRow(this)'> <img src='SIGDOC/ICONOS/SUBMIT.GIF' border='0'></a> <input type='radio' name='cierto' id='cierto'>";

function AddRowsToTable(code) //no necesario pero en caso de que quieras agregar otra cosa
{
var tbl = document.getElementById('tblSample');
var lastRow = tbl.rows.length;
var row = tbl.insertRow(lastRow);
var cellRight = row.insertCell(0);
cellRight.innerHTML=code;
}
function DeleteRow(x)
{
while (x.tagName.toLowerCase() !='tr')
{
if(x.parentElement)
x=x.parentElement;
else if(x.parentNode)
x=x.parentNode;
else
return;
}
var rowNum=x.rowIndex;
while (x.tagName.toLowerCase() !='table')
{
if(x.parentElement)
x=x.parentElement;
else if(x.parentNode)
x=x.parentNode;
else
return;
}
x.deleteRow(rowNum);
}

function RemoveRowFromTable(rowid) {
//alert("sadfs");
var tbl = document.getElementById(iteration);
//var lastRow = tbl.rows.length;
//if (lastRow > 1)
tbl.deleteRow(rowid);
}


function este() //ARREGLAR
{
    elem=document.all?document.all.answers:document.getElementById('answers');
    if(elem.length){
        elem[elem.length].focus();
    }else{
        elem.focus();
    }
}
</script>
</head>

<body>
<form id="formulario" name="formulario" method="post" action="<?=$_SERVER['PHP_SELF']?>">
<table cellpadding="0" cellspacing="0" width="304" border="0">
    <tr>
        <td>
        Respuestas:&nbsp;<input name="button" type="button" onClick="AddRowsToTable(data);este();return false;" value="+" class="Buttonforms"></td>
        
        </td>
    </tr>
    <tr>
        <td>
            <table cellpadding="1" cellspacing="0" width="100%" id="tblSample" border="0">
            </table>
        </td>
    </tr>
    <tr>
        <td>
        <hr>
        <input type="submit">
        </td>
    </tr>
</table>
<hr>
<?php
//obtener valores de answers
$answers=isset($_POST['answers'])?$_POST['answers']:array();

//answers
echo('<b>Valores de answers[]</b>:<br>');
foreach(
$answers as $ans){
    echo(
$ans.' <br>');
}

?>
</form>
</body>
</html>