Best way to do this?

I have a chatroom I have designed and I am still designing. But I have a question on how to do something. I have decided to add a picture to the side of names of people after they type something. So when a person inputs something into the first text field and press’ enter or clicks the enter button, it takes what is in this text field and places it in the one above. But I want it to also place a picture beside the first line of the output. And it does this everytime you enter something.
So what I wanted is to know a good way to do this. I can’t think of a way to do it.