First, I strongly suggest to use a Library or Framework to do your Javascript. But just for something very very simple, or for the fun to learn, it is ok. (you can use jquery, underscore, knockoutjs, angular)
Second, it is not advised to bind directly to onclick, my first suggestion goes in that way too.
That's said What you need is to modify the src of a img in your page.
In the place where you want your image displayed, you should insert a img tag like this:
Next, you need to modify the onclick to update the src attribute. The easiest way I can think of is like his
onclick=""document.getElementById('image-placeholder').src = 'http://webpage.com/images/' + document.getElementById('imagename').value + '.png"
Then again, it is not the best way to do it, but it is a start. I recommend you to try jQuery and see how can you accomplish the same whitout using onclick (tip... check the section on jquery about events)
I did a simple fiddle as a example of your poblem using some google logos... type 4 o 3 in the box and you'll two images of different size. (sorry.. I have no time to search for better images as example)