0

This is my input field in the app

<div class="input-group input-group-sm mb-3 input-field col s6" role="alert">   
       <input id="input0" type="text" value = "<?= initialValue ?>" aria-label="Sizing example input" aria-describedby="inputGroup-sizing-sm" class="input-group-text validate"> 
   </div> 

Here is the js code for change the class of the input box's:

var initVal = document.getElementById('input0').value;
function money() {
  google.script.run.withSuccessHandler(showValue).getNewValue();
}
document.getElementById('app').addEventListener('input', money);
document.getElementById('app').addEventListener('click', money);
document.getElementById('navigation').addEventListener('click', money);
if (initVal <= 0) {
  document.getElementById('input0').classList.add('text-danger');
} else {
  document.getElementById('input0').classList.add('text-success');
  google.script.run.withSuccessHandler(showValue).getNewValue();
}
document.getElementById('input0').value = initVal;
function showValue(myValue) {
  document.getElementById('input0').value = myValue;
}

But my problem is, the text color of the input0 remains the same. Please tell me what did I wrong?

And I have another issue. I want to disable the 'Add Customer' button when the initVal <= 0.

Please check all of the code here : https://github.com/Ashraful7679/USER-FORM-DataSource

And this is the Google sheet: https://docs.google.com/spreadsheets/d/1BhucrjhYGkkkT89djmTaeN5udkcTLcjRNJ83KJbKjic/edit?usp=sharing

TheMaster
  • 45,448
  • 6
  • 62
  • 85
  • 1
    I don't see any code posted that attempts to change the text color of the value of input0 – Cooper Sep 20 '20 at 20:14
  • Sorry for the misleading. – Steven Brock Sep 20 '20 at 20:45
  • @Cooper Will you please check the js section again? – Steven Brock Sep 20 '20 at 20:50
  • I still don't see any code that attempts to change the text color of the value of input0. Also are you waiting to setup your event actions until after dom has loaded? – Cooper Sep 20 '20 at 21:11
  • Dear @Cooper I'm really sorry to say that I'm totally new in js. if(initVal <= 0){ document.getElementById("input0").classList.add("text-danger"); } else{ document.getElementById("input0").classList.add("text-success"); This code works perfectly only onetime. When I start the app the text color works perfectly. But after that it doesn't change anymore. – Steven Brock Sep 20 '20 at 21:15
  • Will you please open this sheet and test the "Custom Menu", the last menu in the list? https://docs.google.com/spreadsheets/d/1BhucrjhYGkkkT89djmTaeN5udkcTLcjRNJ83KJbKjic/edit?usp=sharing You can edit the file. – Steven Brock Sep 20 '20 at 21:20
  • I don't follow links to spreadsheets ever? If you don't post it then I don't see it. – Cooper Sep 20 '20 at 21:31
  • See https://stackoverflow.com/questions/824234/what-is-a-callback-function The if..else should be inside the callback. – TheMaster Sep 21 '20 at 03:24

0 Answers0