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

145
Vistas
I want to make 4 radio button and 1 go button, I want when i check any one radio button and then click on go button then the url will be changeded

World! google
facebook
yahoo
twitter
click to Go✓ if(document.getElementById('google').checked = true) { document.getElementById('btn') .setAttribute("href", "https://google.com"); } else { document.getElementById('btn') .setAttribute("href", "https://example.com"); } if(document.getElementById('facebook').checked = true) { document.getElementById('btn') .setAttribute("href", "https://facebook.com"); } else { document.getElementById('btn') .setAttribute("href", "https://example.com"); } if(document.getElementById('yahoo').checked = true) { document.getElementById('btn') .setAttribute("href", "https://yahoo.com"); } else { document.getElementById('btn') .setAttribute("href", "https://example.com"); } if(document.getElementById('twitter').checked = true) { document.getElementById('btn') .setAttribute("href", "https://twitter.com"); } else { document.getElementById('btn') .setAttribute("href", "https://example.com"); }

about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

Here you go...... You just have to use window.location dom manipulation function of javascript to redirect the user. You can use if-else statement to check which site was selected using querySelector or by any other means. Here is my code for it.

<form>
    <input type="radio" name="site" id="google" /> Google <br />
    <input type="radio" name="site" id="facebook" /> Facebook <br />
    <input type="radio" name="site" id="yahoo" /> Yahoo <br />
    <input type="radio" name="site" id="twitter" /> Twitter <br />
    <hr />

    <button type="submit" onclick="redirect()">Click to go</button>
</form>

javascript code below :-

function redirect() {
        if (document.getElementById('google').checked) {
            document.write("Redirecting...");
            window.location = ("https://www.google.com");
        }

        else if (document.getElementById('facebook').checked) {
            document.write("Redirecting...");
            window.location = ("https://www.facebook.com");
        }

        else if (document.getElementById('yahoo').checked) {
            document.write("Redirecting...");
            window.location = ("https://www.yahoo.com");
        }

        else if (document.getElementById('twitter').checked) {
            document.write("Redirecting...");
            window.location = ("https://www.twitter.com");
        }

        else {
            return;
        }
    }
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