Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9159183
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T13:25:47+00:00 2026-06-17T13:25:47+00:00

I have 2 radio buttons A & B. the B button also have one

  • 0

I have 2 radio buttons A & B. the B button also have one text field.

By default next button is hidden and it should appear in the following cases

  1. If user click button A
  2. User click button B and enter text in the textfield

I try this:

JavaScript

window.onload=function(){
   document.getElementById("next").style.display='none';
} 

function shownext(){
  var A = document.getElementById('A').value;
  var B = document.getElementById('B').value;
  var name = document.getElementById('name').value;
  if(A != "" || (B != "" && name != "")){
  document.getElementById("next").style.display='block';
     return false;
  }
  if(A == "" && B == "" && name == ""){
  document.getElementById("next").style.display='none';
     return false;
  }
}

HTML

<input type="radio" name="A" id="A" value="A" onClick="shownext();"/>
<input type="radio" name="A" id="B" value="B" onClick="shownext();"/>
<input type="text" name="name" id="name" onKeyDown="shownext();" onKeyUp="shownext();"/>

<a href="#q2" id="next"><img src="next.png"/></a>
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-17T13:25:49+00:00Added an answer on June 17, 2026 at 1:25 pm

    You have a syntax error in your first if statement — you’re opening more parentheses than you’re closing.

    Your radio buttons always have a value, so you cannot check their state by just inspecting the value. You need to inspect their checked property instead.

    You also don’t need both ifs, an else to the first if would be more appropriate, since you basically have only two possible outcomes (show the “next” button or hide it).

    Here is a working demo of the fixed code.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have two radio buttons next to each other, and even though each one
I have 2 radio button with values New & Existing. If user chooses New,
i have 3 radio buttons.what i need to do is that when one radio
i have four radio buttons , and i want to set a text for
I have two radio buttons each with a unique ID. When one is clicked,
I have a hidden field called Id on the page. I also have 2
I have a text input area attached to a radio button in an HTML
ok not just checkbox, but also radio button. The thing is I have a
I have a dynamically created list that displays radio buttons next to it. When
I have this javascript inside a rails app: <script type=text/javascript> var buttons = document.querySelectorAll('[data-radio-sub-questions]');

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.