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

122
Visualizações
Is it possible to have a form input text have two action outputs?

What I would like to do is be able to type something into the form input text field and press one of the buttons to search those results to my choosing: Google, Bing, DuckDuckGo or any others I want to add.

I have this:

<form method="get" action="https://www.google.com/search?=">
<input type="reset" />
<input type="text" name="q" autocomplete="off" autofocus />
<input type="submit" value="Google Search"/>
<input type="submit" value="Bing Search"/>
</form>

I did see a post on here but unfortunately, the code wasn't complete: Is it possible to have two actions on a form?

That post showed

<form id="search" action="" method="get" onsubmit="javascript: return SubmitForm();">
<.... ret of the form>
</form> 

and js

function SubmitForm()
{
    showResultDiv();
    document.forms['search'].action='http://www.google.com/search';
    document.forms['search'].target='frame_result1';
    document.forms['search'].submit();

    document.forms['search'].action='http://www.bing.com/search';
    document.forms['search'].target='frame_result2';
    document.forms['search'].submit();
    return false;
}

From the looks of it, it's possible but not sure how. Any ideas without PHP. Just HTML and JS? Thanks for your time.

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

0

You could do it using HTML only.

HTML

<form method="get"  target="blank" >
    <input type="reset" />
    <input type="text" name="q" autocomplete="off" autofocus />
    <input type="submit" value="Google Search" formaction="https://www.google.com/search"/>
    <input type="submit" value="Bing Search"  formaction="https://www.bing.com/search"/>
</form>

I found this here

about 4 years ago · Juan Pablo Isaza Relatório

0

Maybe this is not the best solutions but it work and its more secure than get method. if called win2 before win it will focus on google window.

<form id="form" role="search">
<input type="search" id="query" name="q" placeholder="Search..." aria-label="Search through site content">
<button>Search</button>
const f = document.getElementById('form');
const q = document.getElementById('query');
const google = 'https://www.google.com/search?q=+';
const bing = 'https://www.bing.com/search?q=+'
const site = '';
function submitted(event) {
event.preventDefault();
const urlG = google + site + '+' + q.value;
const urlB = bing + site + '+' + q.value;
const win = window.open(urlG, '_blank');
const win2 = window.open(urlB, '_blank');
win.focus();
win2.focus();
}
f.addEventListener('submit', submitted);
about 4 years ago · Juan Pablo Isaza Relatório

0

This works:

HTML:

<form method="get"  target="blank" >
    <input type="reset" />
    <input id="the-text" type="text" name="q" autocomplete="off" autofocus />
    <button id="submit">Search</button>
</form>

JavaScript:

let search = document.getElementById('submit')
search.addEventListener("click", searchFunction);

function searchFunction() {
let searchText = document.getElementById('the-text').value;
window.open('https://www.google.com/search?q='+searchText)
window.open('https://www.bing.com/search?q='+searchText)
}

Unfortunately, browsers usually block 2 or more tabs opening at the same time. So, you can allow popups, and it will search on both Google & Bing, if popups are blocked, it will only show google's search result and Block Bing

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