Hi, I am just wondering if this is possible I have...
# suitescript
t
Hi, I am just wondering if this is possible I have a suitelet that gets and compute the total per classes. Initially, the script will get the total class whenever you change the value on the interface. But since I scripted the class total value on initial load, I wasn't able to get the total. My question, is it possible to get data from saved search then at the same time accept input change in suitelet + html
Copy code
var classTotal = "<td><input class='input' type='number' step='0.01' value=" + parseFloat(allClasses[className]['classTotal']) + "></td>";
n
Not sure I fully understand, are you saying you want the total to update if a user alters a value on the suitelet page?
t
yes for example.. class1 value change to 2. The total class should be 8
n
and the user changes it manually?
t
yes
n
Strikes me you just need to add onClick events to each class value td. (might not be onClick I don't really "do web dev") Personally I'd have created a NetSuite form and added the fields as native NetSuite fields and not used HTML. That way you could have used a client script fieldChange to re-calculate if any changed value.
t
I see get your point on that. But the fields are dynamic 🤔
n
Dynamic how? You mean there could b 3 one time and 10 the next?
t
yes depending on the saved search result
n
Ok so if you're sticking with the html route I'm sure you can name the id of each row using a numeric as part of the id and just iterate the TR's
row_1, row_2 and in your onclick event get row elements and then gather up the values
t
yeah.. the requirement made me do this 😅
thanks @NElliott. I was thinking if this would not work. Maybe I can introduce a button where it will prompt and then get the value from the input text then sum it up upon clicking 'Ok'
n
I mean you could but an onclick should be perfectly fine. (gotta say it's been 15+ years since I last tried to work with html using JS 😄 ) This may help: https://stackoverflow.com/questions/3065342/how-do-i-iterate-through-table-rows-and-cells-in-javascript
t
what ... thanks for the link..
👍🏻 1