0

I have a form who gives data from database I have number type inputs. I want to hide and leave empty the input that displays "0", without replace it in database after submit.

I found how to do it with table cells. But not with inputs.

 <script type="text/javascript">
var table = document.getElementById("myTable");
var cells = table.getElementsByTagName("td");
for (var i = 0; i < cells.length; i++) {
  if (parseInt(cells[i].textContent, 10) === 0) {
	cells[i].innerHTML = ' ';

  }
}
</script>

Thx.

1 Answer 1

1

Filter input selection by value where it equals 0 with filter() function and then remove these elements from DOM not be submitted with the form with remove() function

   $('input').filter(function() { return $(this).val() === 0; }).remove();
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.