Problem with hiding the checkBox

Cornel

New member
Hi all!
Hope to get any help from you.
I’ve got a list of elements.
This is how they are displayed (along with a 'checkBox' which is used to delete the previously selected elements):
Code:
<tbody id="elementsTableBody">
        <g:if test="${shelfInstance.elements != null && shelfInstance.elements.size() > 0 }">
            <g:each in="${shelfInstance?.elements}" status="i" var="element">
                <tr id="elements_${i}_tr">
                <td> <%=i%> </td>
                <td> <g:checkBox name="elements[${i}].delete_placeholder" id="elements_${i}_delete_placeholder" value="${false}" onclick="toggle(this,'elements_${i}_tr')"/></td>
                <td> <g:textField id="elements_${i}_element_name_placeholder" name="elements[${i}].element_name_placeholder" value="${element?.name}"/></td>
                <td> <g:textField name="elements[${i}].label" value="${element.label}"/></td>
            </tr>
        </g:each>
    </g:if>
</tbody>

I don't want the checkBox to appear when adding new element by cloning (JS function):
Code:
function addElement(an_id) {
    //get list object with specific id set

    var count = parseInt(document.getElementById("elementCount").value);

    var template_tr = document.getElementById("elements_0_tr");

    if ( count == 0 ) {
      template_tr.style.display="";
    }
    else {
      // Clone the first line now its unhidden
      var newNode = template_tr.cloneNode(true);
      newNode.id = "elements_"+count+"_tr";

      var td_elements = newNode.getElementsByTagName("td");
      td_elements[0].innerHTML = ""+count+"";

      var input_controls = newNode.getElementsByTagName("input");

      input_controls[2].name="elements["+count+"].element_name_placeholder";
      input_controls[2].id="elements_"+count+"_element_name_placeholder";
      input_controls[2].value="";

      input_controls[3].name="elements["+count+"].label";
      input_controls[3].id="elements_"+count+"_label";
      input_controls[3].value="";

      $("#elementsTableBody").prepend(newNode);
}

Any help?
Thank you!
 
Top