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

151
Visualizações
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 Respostas
Responde à pergunta

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 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