If statement for a project I am working on

I am creating a form to help a family member with their website but I don’t have a much (or any real) experience with Javascript.

The form part is fine because I have built it is a fairly powerful builder. However, I need to stop rows from showing on a summary if the person using the form don’t select them (they select by changing the value from 0 to any other number).

What I am thinking is code like the follow but I might be well and truly wrong.

if (document.getElementsByClassName("number") > 0) {

So basically what I am trying to do is if the class “number” value = 0 then add another class (option-removal) to everything with the class “input-option”. I could then set css to remove the items with the class “option-removal”.

This may not be the best way of achieving what I am trying to do so I am happy for suggestions.

hey @TylerAPD

im not sure if i have understood you properly but try this out it adds display none to elements with the value of 0

let elements = document.querySelectorAll(".number")

elements.forEach(elem => {
 let num = elem.innerText;
 if(num === '0') {
   elem.style.display = 'none'
} )

if it doesnt work try changing let num = elem.innerText; to let num = elem.value; as im not sure what element you’re using

Hi @biscuitmanz

Thanks for responding. It didn’t work though, would it help if I showed you where the form is?

I’ve edited your post for readability. When you enter a code block into a forum post, please precede it with a separate line of three backticks and follow it with a separate line of three backticks to make it easier to read.

See this post to find the backtick on your keyboard. The “preformatted text” tool in the editor (</>) will also add backticks around text.

Note: Backticks are not single quotes.



Is your code on codepen? the best thing you could do is copy the form code into codepen and share the link so i can try some things out on it then and then send you the working code back.


Hi mate,

The code is in 100 different files. I am not sure if you are familiar with Calculated Field Form the WP Plugin but that is the one I am using and I have made a few css modification.

I don’t know if this is even something anyone can help me with.

I am in a little bit over my head

hey iv never used word press before, have you checked the plugin settings see if there’s something in there? i did see this on the latest added features “Dependent fields from calculated values: Fields can be shown/hidden based on the value of a calculated field " and " * Calculated fields can be hidden fields.”

maybe something like this is what you want?


  • Dependent fields: Fields can be shown/hidden based on other checkboxes, radiobuttons or drop-down selections
  • Dependent fields from calculated values: Fields can be shown/hidden based on the value of a calculated field
  • Troubleshooting area to automatically fix conflicts with other scripts in themes or third-party plugins, and also for special characters’ support
  • Multi page calculated forms
  • New validations, field types and features in the form builder
  • Calculated fields can be hidden fields.
  • Includes new controls to create more versatile forms.
  • Allows to create a cache of the JavaScript files to increase the website’s performance.
  • Allows to disable the forms when the website is visited by search engine spiders and crawlers, increasing the website’s speed.