0

I am new to javascript, so my error may be extremely basic. I did look at similar posts and could not figure out what I am doing wrong with my code.

<form name=dform_8190 method="get">
<input type="submit" style="display:none">
<input type="hidden" name=delete_id id="delete_id">

some other code here

<a onclick="if (confirm('Delete Comment 8190?')) {document.getElementById('delete_id').value=8190; document.getElementById('dform_8190').submit();}">
<img SRC="../images/del_x.png" ALT="archive" title="Archive" border="0">
</a>
</form>

the "Delete Comment 8190" box pops up, but when I select "OK", nothing happens.

asked Dec 4, 2019 at 21:00
3
  • 2
    I believe that the problem is METHOD="GET" which should be METHOD="POST" Commented Dec 4, 2019 at 21:03
  • Getting an error in the console that submit is not a property of undefined? Commented Dec 4, 2019 at 21:04
  • You're using getElementById for a name... That won't work. Change <form name=dform_8190 method="get"> ==> <form id=dform_8190 method="get"> Commented Dec 4, 2019 at 21:04

2 Answers 2

2

Your form doesn't have an ID of dform_8190. You need to add it. Or change your query to

document.querySelector("form[name=dform_8190]").submit()
answered Dec 4, 2019 at 21:04
Sign up to request clarification or add additional context in comments.

Comments

0

Try change name to id: . getElementById uses value of "id" attribute.

answered Dec 4, 2019 at 21:04

Comments

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.