0

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 : '');
});

Edited by Ninja_1

Attachments Screen_Shot_2018-01-23_at_22_08_12.png 63.61 KB
3
Contributors
4
Replies
20
Views
6 Months
Discussion Span
Last Post by Kannu_2
0

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

Edited by Ninja_1

0

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)

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.