Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 676885
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T00:58:42+00:00 2026-05-14T00:58:42+00:00

I swear, I have this exact thing working on another page. I’m such a

  • 0

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&section=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&amp;section=galleries&amp;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>

EDIT:

I should have mentioned I tried using the getElementById method first, ala forms.submit(); – I had the same error, which is why I switched to using document.forms[] instead.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-14T00:58:42+00:00Added an answer on May 14, 2026 at 12:58 am

    It is probably because of this inside the form-

    <input type="submit" value="Submit" name="submit">
    

    form.submit is being redefined with this input. Just change the name from submit to something else, like submit1 and see if that works.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I could swear this was working the other day: var resultSet = (from o
I swear this was working last night which was why I was able to
I swear... i hope this is the last question I have to ask like
I have some code that I would swear was working a month ago. However,
I swear I have seen this done before but can not find it now.
I have this cUrl request that works sometimes, then stops working. I am echoing
I swear i couldn't find a simple working solution for this. On a form
I have a function saving a file to gridfs. It somehow stopped working sporadically
I swear I have seen an example of this but have been googling for
I have a register page that has a file upload button on it. This

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.