Javascript – click on image and change a text

htmljavascript

U have 2 images on a page and a textbox (php)

When u click on the image i want to change the text.

I am a starter, please sent a code that isn't to hard to understand.

<body>
    <img src="bier1.jpg" alt="u mad" onclick= "">
    <img src="bier2.jpg" alt="u mad" onclick= ""><br>

    <form>
    <input type="text" name="Example"/>
    </form>
</body>

Best Answer

Are I'm right that you want to change the text of the Textbox? If yes here's the code:

    <body>
        <img src="bier1.jpg" alt="u mad" onclick= "document.forms[0].elements['Example'].value = 'Image 1'">
        <img src="bier2.jpg" alt="u mad" onclick= "document.forms[0].elements['Example'].value = 'Image 2'"><br>

        <form>
        <input type="text" name="Example"/>
        </form>
    </body>