开发者

HTML, Javascript function

I have a number of input fields that accept numbers. When the calculate button is pressed, the calculations are sent to a number of other input fields with the results. I then have to go and click each of the 开发者_如何学JAVAresult fields to format the contents. I would like to be able to attach code to the calculation button, in order to format all the input result fields at the same time. Is this possible?


Sure, it's possible. You just need to format the results properly before setting the values of the relevant fields.

Unfortunately, unless you can be more specific about your requirements, I can't give you a more specific answer.


Try creating a format function that gets called when each of the fields you want formatted change (using onchange on them). Then just carry out your calculation as before.

You might have to manually trigger the onchange right after setting the calculated value for each input field in order for the format function to run. I haven't tested this.


I cannot format the results properly before setting the values because they will then have commas in the field and the calcualtion will not work. Formatting is done after the calculations and I click each field which is then formatted eg $12,265.00 I would like a function to add it to the Calculation Button

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜