I recommend you to try jQuery and see how can you accomplish the same whitout using onclick (tip. Then again, it is not the best way to do it, but it is a start. The easiest way I can think of is like his onclick=""document.getElementById('image-placeholder').src = '' + document.getElementById('imagename').value + '.png" Next, you need to modify the onclick to update the src attribute. In the place where you want your image displayed, you should insert a img tag like this: What you need is to modify the src of a img in your page. Second, it is not advised to bind directly to onclick, my first suggestion goes in that way too. (you can use jquery, underscore, knockoutjs, angular) But just for something very very simple, or for the fun to learn, it is ok. First, I strongly suggest to use a Library or Framework to do your Javascript.
0 Comments
Leave a Reply. |