kpcollier Posted February 3, 2021 Report Share Posted February 3, 2021 I have a calculated value field (SQFT) that calculates the square footage from user-inputted Width and Height values. I have another text field named SQFT_Override. I am trying to create a script that, if SQFT is less than 3 and not blank, then fill the SQFT_Override value with 3. I can't quite get it to work. First I was trying just a simple if statement with JS. I was able to change the value of SQFT_Override, but I couldn't get it to work with the second condition - SQFT can't be blank. I tried !== null and !== '' and couldn't get it to work. I also had a problem with the script only running once. If the width or height was changed afterwards, thus changing the SQFT value, SQFT_Override would still have '3' as its value. So, I tried wrapping it in a change event, but still can't get it to work. Below is my attempt. Any help would be appreciated. document.addEventListener('DataPageReady', function (event) { document.querySelector('[id*="SQFT"]').addEventListener("change", sqftMinimum); function sqftMinimum(event) { let checker = event.target.value; var putter = document.querySelector('[id*=SQFT_Override]'); if (checker.innerText < 3 && checker.innerText !== null) { putter.value = 3; } else { putter.value = '' } } }); Quote Link to comment Share on other sites More sharing options...
kpcollier Posted February 3, 2021 Author Report Share Posted February 3, 2021 I am not receiving any errors with the script in the original post, but it is not working. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.