[Solved] Can I change the max attribute of an input tag using a function?


If your myVar variable is supposed to get a result from myFunction() (located inside Code.gs), and you want use the result from the said function inside your HTML file, you will find that simply doing this will not work:

var myVar = function() { google.script.run.withSuccessHandler(onSuccess).myFunction()}

The above function will simply return undefined

In order to get the resultant value from myFunction(), and use it to change an input tag attribute inside your HTML file, you will have to write something like this:

function onSuccess(myVar) {
    document.getElementById(*yourID*).setAttribute(*yourTargetAttribute*, myVar);
}; google.script.run.withSuccessHandler(onSuccess).myFunction();

By doing this, we use the onSuccess callback function to store the result from myFunction(), after which we can easily use that result to change any attribute we like.
I hope this helps someone because it certainly solved a major issue for me.

NOTE: Whereas the answer by Exceptional NullPointer works in most cases, for my particular case, the answer I have provided here is the one that worked.

0

solved Can I change the max attribute of an input tag using a function?