Hi all,
How do I take two numeric fields and have the sum be placed in a third field. As the two numbers update, I want to the third box to update in real time. Is that possible?
Hi all,
How do I take two numeric fields and have the sum be placed in a third field. As the two numbers update, I want to the third box to update in real time. Is that possible?
Hi Andre,
Yes, it’s possible. You can add an onchange
custom attribute for the two textboxes for which you want the sum, and in the attribute value you can add some JavaScript code, such as:
document.getElementById("REQUEST_TEXTBOX3").value = parseInt(document.getElementById("REQUEST_TEXTBOX1").value) + parseInt(document.getElementById("REQUEST_TEXTBOX2").value);
Hi All,
Can I add If statement with my JavaScript code in the attribute value?, such as:
if(“REQUEST_DROPDOWNLISTBOX.Items[1].Selected”)
{
document.getElementById(“REQUEST_TEXTBOX3”).value = parseInt(document.getElementById(“REQUEST_TEXTBOX1”).value) + parseInt(document.getElementById(“REQUEST_TEXTBOX2”).value);
}
else
{
document.getElementById(“REQUEST_TEXTBOX3”).value = parseInt(document.getElementById(“REQUEST_TEXTBOX2”).value);
}
Hi Pnicoll,
So I’ve been using this formula you gave but I have a few problems:
I feel like the best way to do this calculation is to use JQuery or .NET in the code behind. What do you think?
Hi Rami,
No, JavaScript accepts only JavaScript language.
You can use JQuery which is the easiest way to retrieve values from fields:
if($(’#REQUEST_DROPDOWNLISTBOX’).val() == “Value of Item 1”){…}
Best Regards,
Eddy.
Hi Andre,
A File Upload field does need to do a postback in order to upload a file. You need to handle postbacks in order to avoid this issue. I would go with using .NET code behind to handle this. Kindly open a ticket in our Helpdesk system if you need further assistance.
Best Regards,
Eddy.
I’m not sure how an IF statement would work here. I just need to add two fields. I need two fields that are Strings to be converted to Integers, added together and inserted into another field. Does that make sense?
Hi Andre,
That reply was for r.tobasi’s question.
Hi @pnicoll
Thanks for your answer, it worked for me for a textbox.
However I try to set it up for a Gridview but I cannot find the good way to make it works.
In my case I try to multiply two datas from the same row into the last column of that same row.
Do you have an idea on how to set it up ?
Thanks in advance,
Thomas.