I need assistance in storing checkbox API values. I have multiple checkboxes and I can display API values in html when checkbox is checked. But how do I store the initial value of a checked checkbox and show it in a span?

I currently get “on” value instead of API initial value instead of "on" value.

eg. The value I want is “Breakfast Event” as stored in the API

Below is my code:

<input type="checkbox" id="myCheck1" name="checks" class="round">
<span id="eventTitle" class="results"></span>

//store checkbox values
 $('#myCheck1').on('change', function() {
    $('.results').html(this.checked ? this.value : '');
});

You wrote API a few times but didn't call out what API you are working with. To me, JavaScript is just that but not an API. So tell more.

Also I see a lot of repeated questions like "How do I store checkbox values?" but the OP's usually forget to check priors. Example DW search follows:
https://www.daniweb.com/search/index?q=how%20do%20i%20store%20html%20checkbox%20values

I need assistance in storing checkbox API values. I have multiple checkboxes and I can display API values in html when checkbox is checked. But how do I store the initial value of a checked checkbox and show it in a span?

I currently get “on” value instead of API initial value.

eg. The value I want is “Faculty Lecture” as stored in the API

You simply use the .prop() method to find the checkbox value.
var myval=$('#myCheck1').prop('checked')

Store in some variable and then use the .text() method of span to put the value.
$('.results').text(myval)

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.