简体   繁体   中英

Can I select the value of an input without a name or ID?

在此处输入图片说明

I am creating a dynamic table (as seen above), but I do so by looping through my data object. Currently you fill out the data in the top section, then click stage, and the data is added to the table. I'd like to be able to update the data in the table as well.

This is how the table is built:

<?php
for($r = 0; $r < sizeof($dataArray); $r++){
    for($i = 0; $i < $fields; $i++){
        Echo "<td>
                  <input onchcange='updateData("WHAT GOES HERE?", ".$r.", ".$i.")' value='".$dataArray[$r][$i]."'>
             </td>";
    }
}
?>

updateData() should take 3 parameters: the ROW, the COLUMN, and the new VALUE.

How can I select the new value from the input?

Pass the input element, or it's value, to the callback:

              <input onchange='updateData(this.value, ".$r.", ".$i.")' value='".$dataArray[$r][$i]."'>

Generally, this in an event handler context points to the element the handler is defined on.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM