How to do this?

I have the following code in my application.

if (posbuttlistener.click){var txt_url="pos.txt"}else { if (invbuttlistener.click)var txt_url="inv.txt"}

I am filling in a text display component dynamically based on buttons that are clicked,so that appropriate txt_url variable is given the selection. But when I play the movie I see that only the first if is working, the else part never works…can anyone help ?TIA!