Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

123
Vistas
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 Respuestas
Responde la pregunta

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 Denunciar

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 Denunciar

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 Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda