Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

371
Visualizações
In HTML/JavaScript how do I submit multiple posts from one button, leading a to a new page being opened on a new tab

How do I submit open multiple pages via a a post request from a single form/button

Currently I have a table with each row representing a song artist and a song and on each row there is an Unlink button that uses a form to submit a post action to a server which results in a new page being opened on a new tab, and this works fine

<form target="_blank" action="https://acoustid.org/edit/toggle-track-mbid" method="POST">
  <input name="state" value="1" hidden="">
  <input name="track_id" value="9509889" hidden="">
  <input name="mbid" value="6573f01d-0df5-442d-90c3-a69783c217c3" hidden="">
  <input type="submit" value="Unlink">
</form>

What I want to be able to do is also have a an Unlink All by Artist button that will find all rows with the same artist as the row clicked on and then submit a post request for each.

So I can find the rows okay using getElementsByName() , my difficulty is I don't understand only to submit multiple posts, with each post resulting a new page being opened in a new tab.

I'm assuming my JavaScript for the UnlinklllByArtist would find the required rows, and then for each row call another JavaScript function to submit the post but how do I do this second part.

about 4 years ago · Juan Pablo Isaza
2 Respostas
Responde à pergunta

0

You can trigger multiple button clicks / submits with one button click, but my browsers initially won't allow a website to open multiple tabs. I get a message, that tabs / popups were blocked. I have the option to allow this action.

document.querySelector('button').addEventListener('click', () => {
  const forms = document.querySelectorAll('form');
  forms[0].submit();
  forms[1].submit();
});
<form target="_blank" action="https://acoustid.org/edit/toggle-track-mbid" method="POST">
  <input name="state" value="1" hidden="">
  <input name="track_id" value="9509889" hidden="">
  <input name="mbid" value="6573f01d-0df5-442d-90c3-a69783c217c3" hidden="">
  <input type="submit" value="Unlink">
</form>
<form target="_blank" action="https://acoustid.org/edit/toggle-track-mbid" method="POST">
  <input name="state" value="1" hidden="">
  <input name="track_id" value="9509889" hidden="">
  <input name="mbid" value="6573f01d-0df5-442d-90c3-a69783c217c3" hidden="">
  <input type="submit" value="Unlink">
</form>
<button>
  Unlink All
</button>

about 4 years ago · Juan Pablo Isaza Relatório

0

I found a solution using GreaseMonkey

This find each form and then submit to same tab in turn with a delay between each submission

// ==UserScript==
// @name     AlbunackSubmitBadAcoustidsLinksOnPage
// @version  1
// @grant    none
// @include  http://reports.albunack.net/new_acoustid_report10_1.html
// ==/UserScript==
function delayedOpenLink(form)
{
    form.submit();  
}

function check()
{
  var forms = document.getElementsByTagName("form");
  var i=1;
  for(form of forms)
  {
    setTimeout(delayedOpenLink, 5000 * i, form);
    i++;    
  }
}

if (confirm("SubmitAcoustIds") == true) 
{
  check();
} 
about 4 years ago · Juan Pablo Isaza Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda