What is best to solve this issue?

What is best to solve this issue. Display 3 textbox if i enter the 3 in number field. which i have done. now i want to add these 3 textbox values. added values is showing in total field but not in database. I have solved this problem with repeat group

Welcome to the community, @vinaymaurya84! Could you kindly elaborate on your issue so that the community should be able to help you out? At the moment, it seems like your issue is a bit unclear.

Information being collected - No. of medications that were given; frequency of each medication and the no. of days that the medicine was given.
Output required - Total medicines = Sum of (frequency x duration) for each medication

Depending on the number of medications given to the patient, that many event questions (frequency and duration) are to be generated. For eg. if the patient is receiving 3 medications then 3 textboxes for frequency and duration should be displayed, if 4 then 4 and so on.
To get the final output, i need to multiply the frequency and duration for each medication and then add all these numbers together. As per the screenshot formula uploaded, when we enter the details for 4 medicines, the output is displayed and also stored in the database. But when < 4 medications are entered, the final output is displayed but it is not stored in the database.
We understand that when the no. of medicines are <4, then there are undisplayed textboxes (values), hence it is not being computed in the calculation field. When we use “if condition” command we are able to circumvent this problem. But we need to enter upto 60 medications, which makes the “if condiction” very cumbersome.
How can this problem be solved without using repeat group?

@vinaymaurya84, maybe the best and easiest option would be to use the repeat group.

BTW, I also advise you to use the coalesce function to overcome the non-response variables by following this post discussed previously: