document.forms.gallery_form.submit is not a function
Posted
by Keene Maverick
on Stack Overflow
See other posts from Stack Overflow
or by Keene Maverick
Published on 2010-03-19T22:13:32Z
Indexed on
2010/03/19
22:21 UTC
Read the original article
Hit count: 198
JavaScript
I swear, I have this exact thing working on another page. I'm such a javascript noob it's embarrassing...
function delete_gallery() {
var gallery = document.getElementById('gallery_id').value;
var form = document.getElementById('gallery_form');
form.setAttribute('action', 'index.php?action=delete§ion=galleries&id='+gallery);
document.forms['gallery_form'].submit();
}
Inspecting the element shows that it's updating the action correctly :
<form method="post" action="index.php?action=delete&section=galleries&id=12" name="gallery_form" id="gallery_form"><input type="hidden" value="12" id="gallery_id" name="gallery_id"><p>Name: <input type="text" name="name" value="Woo"></p><p>Description:<br><textarea name="description">Dee</textarea><input type="hidden" value="2" name="artist"></p><p><input type="submit" value="Submit" name="submit">
</p></form>
Here's the button I use to call the function, it's in a table below the form:
<button onclick="delete_gallery()" type="button">Delete Gallery</button>
© Stack Overflow or respective owner