There are two approaches.
If you wish to use AcroForm technology, then you would need to write a bunch of JavaScript to enable this. It has been done, but it’s not trivial.
If you wish to use XFA technology, then it can be setup to happen automatically.
Be aware that in both cases, even though both technologies are part of the PDF standard, that the forms will only be usable in this manner in Adobe’s viewers as many others don’t support JavaScript or XFA.