Guest User

Guest User

  • Tech Writer
  • 2.1k
  • 472.3k

How to make tag attribute ID unique in Jquery

Nov 19 2019 3:02 AM
Hi Team
 
I have an ID in my Button for download, i am using it on my Jquery and referencing to my Jquery document for load to page. But my last fields is overrided with first field and causes data redudant. Please help to find a way to avoid it, meaning each time first field is checked, it ignore the first one and reference last one and pull out data from my thingspeak channel as incorrect data. I want my ID for that field to be unique so it will download it successfully. 
 
<!---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() {
$('#temperature').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 ncount = 0;
if($('#illuminance').prop('checked')) ncount--;
if(ncount < 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 qcount = 0;
if($('#button-state').prop('checked')) qcount--;
if(qcount < 1) {
window.location.href ='https://api.thingspeak.com/channels/899906/fields/8.csv';
}
});
});
 

Answers (1)