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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T06:04:31+00:00 2026-06-16T06:04:31+00:00

I would like the user to select/check a radiobutton (for this example I used

  • 0

I would like the user to select/check a radiobutton (for this example I used directions). With a button you can append some elements to another div (sidebar).

What I would like to accomplish:
Depending on wich radiobutton is checked, I want another image/div to append. So when ‘Left’ is checked, I want the ‘.Left’ div to append (instead of the value). How can I accomplish this?

Hope you can help me out. I’m looking for a clear explaination.

HTML

    <div>
        <input type="text" name="itemtitle" id="itemtitle" value="Title" />
        <br/>
        <input type="radio" id="up" name="direction" value="Up" />  Up
        <input type="radio" id="down" name="direction" value="Down" /> Down
        <input type="radio" id="left" name="direction" value="Left" />  Left
        <input type="radio" id="right"name="direction" value="Right" /> Right
        <button id="addbutton">add it</button>
      </div>

<div id="sidebar"><h1>Sidebar</h1>

</div>

JS

$('#addbutton').click(function() {

    var $addDiv = $('<div></div>', {
        'class': 'bluebox'
    }).html($('#itemtitle').val() + ' ' + $('input[name="direction"]:checked').val() + '<input type="button" class="removebtn" value="." id="removebtn"/>');


    if ($('input[name="direction"]:checked').val() == 'Left') {

        $('.Left').appenTo($addDiv);

    }

    $('#sidebar').append($addDiv);


    $('.removebtn').live('click', function() {
        $(this).parent().remove();


    });
    $('.bluebox').draggable({
        revert: true
    });


});

JSFIDDLE

  • 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-16T06:04:32+00:00Added an answer on June 16, 2026 at 6:04 am

    If you want to put something instead of the value, the first thing that comes to mind is this:

    $('#addbutton').click(function() {
    
        var $addDiv = $('<div></div>', {
            'class': 'bluebox'
        }).html('<input type="button" class="removebtn" value="." id="removebtn"/>');
    
         if ($('input[name="direction"]:checked').val() == 'Left') {
    
            $('.Left').prependTo($addDiv).fadeIn();
    
        }
        else{
              $addDiv.prepend($('#itemtitle').val() + ' ' + $('input[name="direction"]:checked').val());
        }
    
    
        $('#sidebar').append($addDiv);
    
    
        $('.removebtn').live('click', function() {
        $(this).parent().remove();
    
    
        });
    
        $('.bluebox').draggable({
            revert: true
        });
    
    
    });
    

    I have changed the first $addDiv assignment to add only the remove button. Then, if it’s left I add the div and if it’s another one I add the input value.

    Also, you hadn’t a <div class="left"></div>

    You can see it working here

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

Sidebar

Related Questions

I am validating some check boxes and would like for the user to be
I would like the user to select the time in javascript and to avoid
I am learning some myqli and would like to make a simple check. Basically,
What I would like to achieve here is a user selects an operator, e.g.
I'm using Authlogic with my Ruby on Rails App. I would like user to
I would like the user to be able to view a hyperlink to my
I would like the user to add several pins to a map to represent
I would like the user to be able to edit the title of the
I'm developing an ASP.NET Web app and would like the user to be able
My app displays a list of albums and I would like the user to

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.