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 7733279
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T06:56:53+00:00 2026-06-01T06:56:53+00:00

I did mockups in balsamiq & they have this nice widget, which Allowed to

  • 0

I did mockups in balsamiq & they have this nice widget, which

  • Allowed to select a value, out of two values. Works really nicely on touchscreens
  • Can be used to Display two values & highlighting the selected one

Example:
Widget

What the options to implement a widget similar to shown in picture via HTML/CSS & JS?

  • 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-01T06:56:54+00:00Added an answer on June 1, 2026 at 6:56 am

    The approach I present below iterates through all fieldset elements, and if all the inputs therein are of type="radio", hides them and appends span elements (of class="buttonRadio") in their place, using the text from their relevant label elements. It also binds click events to the appended span elements, and triggers the change event on the original inputs and also adds the ‘checked’ class-name to the clicked/touched element, while removing that class it from its siblings:

    $('fieldset').each(
        function() {
            var legend = $(this).find('legend').text();
            if ($(this).find('input').length == $(this).find('input[type="radio"]').length) {
                var that = $(this),
                    len = that.find('input[type="radio"]').length;
                for (var i = 0; i < len; i++) {
                    $('<span />')
                        .text($('label')
                              .eq(i).text())
                        .addClass('buttonRadio')
                        .attr('data-fromID',that.find('input:eq(' + i + ')').attr('id'))
                        .appendTo(that);
                }
            }
        }).on('click','.buttonRadio',function(){
            var id = $(this).attr('data-fromID');
            $(this).addClass('checked').siblings().removeClass('checked');
            $('#' + id).click().trigger('change');
        }).find('label, input[type="radio"]').css('display','none');​
    

    This uses the following CSS to style those elements:

    .buttonRadio {
        background-color: #fff;
        padding: 0.5em 1em;
        border: 1px solid #000;
        margin: 0.5em 0 0 0;
    }
    
    .buttonRadio.checked {
        background-color: #ffa;
    }​
    

    JS Fiddle demo.


    Edited to amend the jQuery a little:

    1. cached the $(this) object a little earlier in this version,
    2. remembered to use the legend variable that I assigned in the first incarnation but forgot to actually use…sigh.
    3. also hid the actual <legend></legend> element:

      $('fieldset').each(
          function() {
              var that = $(this),
                  legend = that.find('legend').text();
              $('<span />').text(legend).addClass('legend').appendTo(that);
              if (that.find('input').length == that.find('input[type="radio"]').length) {
                  var len = that.find('input[type="radio"]').length;
                  for (var i = 0; i < len; i++) {
                      $('<span />')
                          .text($('label')
                            .eq(i).text())
                          .addClass('buttonRadio')
                          .attr('data-fromID',that.find('input:eq(' + i + ')').attr('id'))
                          .appendTo(that);
                  }
              }
          }).on('click','.buttonRadio',function(){
              var id = $(this).attr('data-fromID');
              $(this).addClass('checked').siblings().removeClass('checked');
              $('#' + id).click().trigger('change');
          }).find('label, input[type="radio"], legend').css('display','none');​
      

    JS Fiddle demo.

    References:

    • addClass().
    • attr().
    • click().
    • css().
    • each().
    • eq().
    • find().
    • on().
    • removeClass().
    • siblings().
    • text().
    • trigger().
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Did someone create a nice stylesheet for this: http://mvccontrib.codeplex.com/wikipage?title=Grid&referringTitle=Documentation&ProjectName=mvccontrib Thanks. Christian
Did quite a bit of research trying to figure out how to get this
Did you ever have to choose between WISA or LAMP at the beginning of
did someone else encounter this problem? I use the methods PopUpManager.createPopUp() and PopUpManager.centerPopUp() to
Did anyone create a Document Management System using SQL SERVER's Filestream? By this I
Did a quick search but could not find anything about this. I guess all
Did I missed anything during this? I am running a this command from command
Did anyone integrated Amobee SDK into Android application on ActionScript or Java? I have
Did you ever have a day when nothing works? Now I can't even succeed
Did anybody know more information about this attack ? I recently got this script

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.