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

  • Home
  • SEARCH
  • 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 8799153
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T00:15:07+00:00 2026-06-14T00:15:07+00:00

I have the following code: <fieldset id=dificuldade> <legend>Dificuldade:</legend> <input type=radio name=dificuldade value=facil> Fácil </input>

  • 0

I have the following code:

    <fieldset id="dificuldade">
        <legend>Dificuldade:</legend>
        <input type="radio" name="dificuldade" value="facil"> Fácil </input>
        <input type="radio" name="dificuldade" value="medio"> Médio </input>
        <input type="radio" name="dificuldade" value="dificil"> Difícil </input>
    </fieldset>

    <fieldset id="tipo">
        <legend>Tipo de jogo:</legend>
        <input type="radio" name="Tipodejogo" value="somar"> Somar </input>
        <input type="radio" name="Tipodejogo" value="subtrair"> Subtrair </input>
        <input type="radio" name="Tipodejogo" value="dividir"> Dividir </input>
        <input type="radio" name="Tipodejogo" value="multiplicar"> Multiplicar </input>
    </fieldset>

    <input type="button" value="Começa" id="button" ></input>
</form>

and here is the jsfiddle with both the html and the js http://jsfiddle.net/3bc9m/15/ . I need to store the values of the 2 fieldset so I, depending on the values picked can generate a game, but my javascript isn’t returning any of them. What is wrong? I’ve been told that JQuery is much easier but i can’t use it.

  • 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-14T00:15:08+00:00Added an answer on June 14, 2026 at 12:15 am

    Your code on jsFiddle seems to be working fine for the most part. The only thing was that the elements output and output2 don’t exist on the page.

    So this code that was supposed to display the selected values wasn’t working:

    document.getElementById('output').innerHTML = curr.value;
    document.getElementById('output2').innerHTML = tdj.value;
    

    The part that actually retrieves the selected values is working fine.

    Just add those two elements to the page, like this:

    <p>Selected Values:</p>
    <div id="output"></div>
    <div id="output2"></div>
    

    An updated jsFiddle can be found here.

    EDIT

    If a radio button from only one of the sets is selected, the code fails. You could use this code to find the selected values instead:

    document.getElementById('button').onclick = function() {
    
        var dif = document.getElementsByName('dificuldade');
        var tip = document.getElementsByName('Tipodejogo');
    
        var difValue;
        for (var i = 0; i < dif.length; i++) {
            if (dif[i].type === "radio" && dif[i].checked) {
                difValue = dif[i].value;
            }
        }
    
        var tipValue;
        for (var i = 0; i < tip.length; i++) {
            if (tip[i].type === "radio" && tip[i].checked) {
                tipValue = tip[i].value;
            }
        }
    
        document.getElementById('output').innerHTML = difValue;
        document.getElementById('output2').innerHTML = tipValue;
    };​
    

    An updated jsFiddle is here.

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

Sidebar

Related Questions

I have the following code: <form class=form-inline id=myform0> <fieldset> <label class=radio><input type=radio name=optionsRadios id=optionHere2
I have following html. <fieldset id=fieldset-step_3> <input type=text value=2 id=rule_form-lead_time name=rule_form[lead_time]> <select class=w50 id=rule_form-operator
I currently have the following code: <form action=process.php method=POST> <fieldset class=form-search> <input type=text class=input-text
I have the following code: <fieldset> <legend>Do you currently have SolidWorks</legend> <ul> <li><label for=><input
I have the following code... <h3>Guests</h3> <form class=form-inline> <fieldset> <label class=control-label for=input01>First Name:</label> <input
i have the following jquery code: $(document).ready(function() { $('.restrictiveOptions input[type!=checkbox], .restrictiveOptions select').change(function() { //
I have the following View code: @using (Html.BeginForm(Login, Press, FormMethod.Post)) { <fieldset> <legend>User Registration</legend>
I have the following html code:- <!DOCTYPE html> <html> <body> <fieldset> <legend> <button> Show/Hide
I have the following HTML code: <fieldset> <legend><span>Contact Details</span> <span class=edit1>Edit</span><span class=hide1>Hide</span></legend> <div> <!--content-->
I have the following code: <fieldset> <legend> <strong>Personal Information</strong> </legend> <ul> <li> <label for=first_name>First

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.