Dear forum, I am struggling with a JavaScript form submission. I have a background photo that i use on all of my pages (site-wide). I also made a form which will allow users to select a background from many choices. I store the background name in a database along with the member information. Each photo available is wrapped in a form, thus each input has a unique name which is actually the name of the photo without the extension. So a photo named “phphelp.jpg” will become input name=“phphelp”.
Now, everything is working well. However, i wanted to allow a user to click on the entire div to submit the form and not just on the button. I should also mention that all buttons have the same value.
I added onclick=“document.getElementById(‘phphelp’).submit();” to the image inside the div, which is wrapped with the form tag. The form submits but the name is not being passed in the submission. Why is this not working? better yet, how can submit an input name using javascript?
I remember i had trouble once with a form and it turns out that the value is passed instead of the name but i can’t remember what causes this action.
Anyone able to offer a solution?