I have created a table using HTML. The first cell of the table (1,1) contains an image that I want to function as a button. When the image is clicked, I would like to be able to select a photo from my computer and add it to the next available cell in the table, if there are any free cells left. I am new to HTML, CSS, and JavaScript, and despite searching for answers, I have not found a solution.
In addition, I understand that in order to use an external JavaScript file, I need to include it in the head or body of the HTML document using
<script src="nameofjs"></script>
. My question is: should I write all the necessary functions and variables in the JavaScript file without the script tag? And then only call the specific ones I need in the HTML code?
My questions are:
- How can I make the image act as a button?
- How do I use this image button to upload an image from my computer?
- How can I ensure the uploaded image goes into the next available cell?
- Where should I insert the new code within the existing code?
Below is the current code for the table:
<table class="imagestable">
<tr class="firstrow">
<td class="imagebox"><img class="tableimage" src="C:\Users\AncaAlexandra\Desktop\Proiect multimedia\addimageicon.png"></td>
<td class="imagebox">
</td>
<td class="imagebox"></td>
<td class="imagebox"></td>
</tr>
<tr class="secondrow">
<td class="imagebox"></td>
<td class="imagebox"></td>
<td class="imagebox"></td>
<td class="imagebox"></td>
</tr>
<tr class="thirdrow">
<td class="imagebox"></td>
<td class="imagebox"></td>
<td class="imagebox"></td>
<td class="imagebox"></td>
</tr>
<tr class="fourthrow">
<td class="imagebox"></td>
<td class="imagebox"></td>
<td class="imagebox"></td>
<td class="imagebox"></td>
</tr>
</table>
Thank you in advance. Attached is a screenshot showing the current state of the project.