Gcobani Mkontwana

Gcobani Mkontwana

  • 568
  • 1.9k
  • 406.4k

Making your ID element not to duplicate data in Jquery

Nov 19 2019 7:30 AM
Hi team
 
I want to find a way to make my ID element not to duplicate data in my Jquery, basically my Jquery needs to reference my ID element from my button ID. I have one button that has ID element, this ID is been referenced on my Jquery for the checkbox. Problem i am having now, that ID from my button is making a duplication not to distinguish itself from other checkbox reference. Is there way that is better, where i can amend my ID not to reference on ID element throughout my document element on Jquery?
 
<!---Downloading File using
Jquery with Buttons---->
<div class="form-group"><br>
<div class="col-md-1.9 text-center">
<button id="download" name="download" class="btn btn-warning">Download</button><br>
</div>
</div>
// checking for one field entry to read.
$(document).ready(function() {
$('#download').click(function() {
var xcount = 0;
if($('.temperature').prop('checked')) xcount--;
if(xcount < 1) {
window.location.href ='https://api.thingspeak.com/channels/899906/fields/1.csv';
}
});
});
// checking for two field entry to read.
$(document).ready(function() {
$('#download').click(function() {
var mcount = 0;
if($('#illuminance').prop('checked')) mcount--;
if(mcount < 1) {
window.location.href ='https://api.thingspeak.com/channels/899906/fields/2.csv';
}
});
});
// checking for third entry to read.
$(document).ready(function() {
$('#download').click(function() {
var tcount = 0;
if($('.button-state').prop('checked')) tcount--;
if(tcount < 1) {
window.location.href ='https://api.thingspeak.com/channels/899906/fields/8.csv';
}
});
});
 

Answers (1)