I have a problem with my google apps script. I have created a dropdown select element that gets values from json and Im trying to pass the selected value back to code.gs within a variable. How can i accomplish this? The json data comes from the function "join". Im trying to get the "id" variable to be used in the api call.
Here's my html file:
<!DOCTYPE html>
<html>
<head>
<base target="_top">
</head>
<body>
<select id="droplist">
</select>
<button type="button" onclick="values()" >Hae</button>
<script>
(function () {
google.script.run.withSuccessHandler(
function(people) {
var select = document.getElementById("droplist");
for( var a of people) {
var option = document.createElement("option");
option.text = a[0] + " " + a[1];
select.add(option);
}
}
).getPeople();
}());
function values() {
var x = []
x.push.document.getElementById("droplist").selectedIndex;
alert(document.getElementsByTagName("option")[x].value);
Logger.log(x)
}
</script>
</body>
</html>
And here's code.gs function where im trying to get the data:
function join(x) {
var id = [];
id.push(x)
Logger.log(x)
Logger.log(id);