Saturday, 30 July 2016

How to transfer selected data from one div to another

<!doctype html>
<html lang="en">
<head>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width, initial-scale=1">
  <title>Add, Remove, Clear Using jquery</title>
 
  <link rel="stylesheet" href="http://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css">
  <link rel="stylesheet" type="text/css" href="https://maxcdn.bootstrapcdn.com/font-awesome/4.6.3/css/font-awesome.min.css">
  <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery.min.js"></script>
  <script src="http://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/js/bootstrap.min.js"></script>
  <script src="https://code.jquery.com/jquery-1.12.4.js"></script>
  <script src="https://code.jquery.com/ui/1.12.0/jquery-ui.js"></script>
  <script>
  $( function() {
    $( "#selectable" ).selectable();
  } );
  </script>
  <script>
  $( function() {
    $( "#second-box1" ).selectable();
  } );
  </script>
<script>
$(document).ready(function(){
    $("#add").click(function(){
        $(".ui-selected").appendTo("#second-box1");
        $( "#second-box1" ).children().removeClass("ui-selected");
    });
});
</script>
<script>
$(document).ready(function(){
    $("#remove").click(function(){
        $(".ui-selected").appendTo("#selectable");
        $( "#selectable" ).children().removeClass("ui-selected");
    });
});
</script>
<script>
$(document).ready(function(){
    $("#clear").click(function(){
        $("#second-box1").children().appendTo("#selectable");
       
    });
});
</script>

<style>
  #selectable .ui-selecting { background: #FECA40; }
  #selectable .ui-selected { background: #F39814; color: white; }
  #selectable { list-style-type: none; margin: 0; padding: 0; width: 100%; }
  #selectable li { margin: 3px; padding: 0.4em;  }
  #second-box1 .ui-selecting { background: #FECA40; }
  #second-box1 .ui-selected { background: #F39814; color: white; }
  #second-box1 li { margin: 3px; padding: 0.4em; list-style: none;}
  .box-two {border: 1px solid #9d9d9d; margin-top: 10px; min-height: 311px; padding: 20px;}

</style>
</head>
<body>


<div class="container">
<div class="row">
          <div class="col-xs-4">
            <button id="add" class="btn btn-default" type="button">Add </button>
          </div>
          <div class="col-xs-4 text-center">
            <button id="clear" class="btn btn-default" type="button">Clear Section</button>
          </div>
          <div class="col-xs-4 text-right">
            <button id="remove" class="btn btn-sign-default" type="button">Remove</button>
          </div>
          </div>
          <div class="row">
                    <div class="col-xs-6">
                        <div class="box-two" id="first-box1">
                            <ol id="selectable">
                              <li class="ui-widget-content grey">Create Users</li>
                              <li class="ui-widget-content grey">Edit Users</li>
                              <li class="ui-widget-content grey">Delete Users</li>
                              <li class="ui-widget-content grey">Create Jobs</li>
                              <li class="ui-widget-content grey">Edit Jobs</li>
                              <li class="ui-widget-content grey">Delete Jobs</li>
                              <li class="ui-widget-content grey">View Jobs</li>
                              <li class="ui-widget-content grey">View Users</li>
                              <li class="ui-widget-content grey">View Applicants</li>
                            </ol>
                        </div>
                    </div>
                    <div class="col-xs-6">
                        <div class="box-two" id="second-box1">
                               
                        </div>
                    </div>
          </div>
 </div>
</body>
</html>

No comments:

Post a Comment