On my HTML page, I have an AJAX submit script that loads a PHP script containing a form with just one input field for comments. This form is submitted via AJAX using the POST method.
Now, I am looking to create a JavaScript function that can be triggered when clicking on a link. This function will be embedded in the PHP form page, which already contains some JavaScript code.
I have a total of 10 different images and I want each image to call this function when clicked.
<a id="image_1" href="javascript: void(0);" onClick="newFunction(this.id)"> Image </a>
The purpose of this function is to extract the value entered in the form's text box, append it with the ID of the clicked image, and then display this new string in the text box itself.
The form has a name and ID of 'myform', and the text box has a name and ID of 'comments'.
While this task may seem straightforward, I must admit that I'm still in the process of learning JavaScript. Any guidance would be greatly appreciated :)