I have a list of elements(a list of book titles) and to the right a label to delete the title from the list.
I want to get the name of the book next to the label i choose and delete it.
My problem is that every element of that list has a name which change from an index.
To better explain me, here is my code:
<?php foreach($xmlenviar->entryresult as $entry):?>
<tr>
<td><?php echo $entry->author;?></td>
<td" colspan="2"><?php echo $this->Form->input('criterio' . $j, array('options' => $options, 'label' => "")); ?></td>
<td><p onclick="myfunction2()"> Delete it. </p></td>
<?php ++$j; ?>
</tr>
<?php } ?>
I want to click on a label and delete the book which correspond to that lines of the label. I have tried my custom.js but i only delete the first line
At the end, my code is: custom.js:
function cambio(indicetabla, indicexml, etapa, carpeta){
var table = document.getElementById('table').tBodies[0];
var rowCount = table.rows.length;
document.getElementById("table").rows[indicexml].cells[1].innerHTML = "Null";
}
in my view.ctp:
<?php foreach($xmlenviar->entryresult as $entry):?>
<tr>
<td><?php echo $entry->author;?></td>
<td" colspan="2"><?php echo $this->Form->input('criterio' . $j, array('options' => $options, 'label' => "", 'onclick' => cambio($j))); ?></td>
<?php ++$j; ?>
</tr>
<?php } ?>
When selecting a combobox, it passes the index $j to the function and the function changes the name of that row (cell 1) to "Null". And that works for me.