Obtain data- from a checkbox and when selected show data value- in a [duplicate] input

0

I'm doing an office booking website (PHP, MySql), to book a time it shows a table where the start time, end time, availability and price, every hour has a checkbox at the end to select it, all right up there, what I need is that when you click, show in some input (text) the values that I have assigned with data (data-time-start and data-time-term)

    
asked by Omar 06.03.2017 в 03:51
source

1 answer

2

You can use the Jquery click

$(document).ready(function(){
  
  $(".checkbox").click(function(){
    var data_inicio = $(this).attr("data-hora-inicio");
    
    alert(data_inicio);
  })

})
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<label>Ejemplo checkbox</label>
<input class="checkbox" type="checkbox" name="checkbox" data-hora-inicio="8"/>
    
answered by 06.03.2017 в 04:43