Hi there Toton, what you require is a tutorial on state management. Try googling this as there are thousands out there. To get you started I have found one which I believe suits your problem well :
Hope this helps
Reputation Points: 256
Solved Threads: 72
Nearly a Posting Virtuoso
Offline 1,306 posts
since Oct 2007