Get class of a clicked image and modify corresponding form field
<p>I'm stuck with this task:</p>

<p>I have a function attached with onclick="myFunction(this);" to tens of images of my page.
Inside the function I retrieve the class name of the clicked image.
Lastly I would like to look inside a html form and modify an input field with the same id as the retrieved class.</p>

<p>Here is an example to clarify:</p>

<ol>
<li>User clicks on image with class="green"</li>
<li>We find the input field of a form with the id="green" and change it's value to 1</li>
</ol>

<p>or</p>

<ol>
<li>User clicks on image with class="red"</li>
<li>We find the input field of a form with the id=red" and change it's value to 1</li>
</ol>

<p>and so on..</p>

<p>I have most of the code but what I dont seem to get is how I should use the retrieved class of an image to find a corresponding id in the form.</p>
