Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

142
Views
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 answers
Answer question

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 Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!