0

I'm trying to figure out what is probably a simple script but I'm really bad at js.

I have a button that I want to reset fields that are dynamically created.

<button type="reset" onclick="clearDiv_<?php echo $mid; ?>();"><?php echo $reset ?></button>

I have a script attached to each field

function clearDiv_<?php echo $mid; ?>() {
    var t = '<?php echo $id.'_output'; ?>'; 
    var getDiv = document.getElementById( t );
    var emptyDiv = getDiv.innerHTML = "";
}

Basically each field is assigned a group ID ($mid). The $id is the individual field ID. Looking at the outputted HTML it looks like it should clear all of the fields but it's only clearing the last field in the group. How can I make it work and trigger each of the fields the script is attached to?

4

0 回答 0