I have created a google sheets sidebar using the google script HTML service which has various text boxes and checkboxes. i have no problem passing the variables through to the google script. The problem i have is that the value of my checkbox is always true or "Y" in my case whether is is checked or not. I really would like to know how to set the value as "Y" or "N". I wont upload complete script just the important bits because they are quite long.
This is my checkbox within my sidebar HTML...
</div>
<div class="block form-group" id="Headset">
<label for="headset-Check">Headset?:</label><br>
<input id= "headset-Check" type="checkbox" value="Y">
</div>
this is my javascript calling various google script functions the bit that uses the checkbox is near the bottom,
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"> </script>
<script>
$(function() {
// Assign handler functions to sidebar elements here, if needed.
$('#GetSerial-button').click(onGetSerialClick);
$('#Submit-button').click(onSubmitClick);
});
function onGetSerialClick() {
this.disabled = true;
google.script.run
.withSuccessHandler(
function(msg, element) {
$('#Serial-value').val(msg);
showStatus('Pulled Serial Successfully.');
element.disabled = false;
})
.withUserObject(this)
.getSerialValue();
}
function onSubmitClick() {
this.disabled = true;
var serial = $('#Serial-value').val();
var warrantyNotes = $('#warrantyNotes-value').val();
var warrantyRepair = $('#Warranty-Repair').val();
var headsetCheck = $('#headset-Check').val();
google.script.run
.withSuccessHandler(
function(msg, element) {
showStatus('Submitted ');
element.disabled = false;
})
.withUserObject(this)
.setHeadsetValues(warrantyRepair,headsetCheck,warrantyNotes,serial)
google.script.run
.addNewRow();
}
function showStatus(msg, classId) {
$('#sidebar-status').removeClass().html(msg);
if (classId) {
$('#sidebar-status').addClass(classId);
}
}
i then have a GS function to put the variables into correct sheet.
Aucun commentaire:
Enregistrer un commentaire