- Local time
- Today, 21:40
- Joined
- Jul 9, 2003
- Messages
- 17,386
Excellent, easy to follow explanation.
Excellent, easy to follow explanation.
Maybe you will post the sample URL?![]()
function doGet(e) {
//Log the URL parameters
Logger.log(JSON.stringify(e));
//Test the Logging
Logger.log("Create HTML");
return HtmlService.createHtmlOutputFromFile("page");
}
function userClicked(xname) {
//URL of the Spreadsheet
var url = "https://docs.google.com/spreadsheets/d/1nCOYb_5PFAPl7DzOIio3Yss-zlrgBIHtlcyPA3Q__YA/edit#gid=0";
var ss = SpreadsheetApp.openByUrl(url);
//Spreadsheet Page AWFName
var ws = ss.getSheetByName("AWFName");
ws.appendRow([xname, new Date()]);
//Logger.log(xname + " >>> Clicked the Button");
}
<!DOCTYPE html>
<html>
<head>
<base target="_top">
</head>
<body>
<h1>HELLO WORLD!!!</h1>
<!--Setup the Textbox-->
<label for="name">Name:</label><br>
<input type="text" id="name" name="name"><br>
<!--Setup the Button-->
<button id="btn"> RUN IT!!!</button>
<script>
document.getElementById("btn").addEventListener("click",doStuff);
function doStuff(){
//Pass the name from the Textbox into a Variable "username"
var username = document.getElementById("name").value;
//Run the function "userClicked" in the Google Script file - Code.gs
//and pass through the variable username
google.script.run.userClicked(username);
//Set the name textbox to no value ""
document.getElementById("name").value = "";
}
</script>
</body>
</html>
Hi uncle, is the privacy set just for you or can anyone see the table / sheet.
My next test of this a problem will be to create a new Google apps script and add the information to Two new spreadsheets simultaneously, then comment out one and the then the other to see what happens. ...
function doGet(e) {
Logger.log("doGet Ran");
//Create the Data Collection Web Page
return HtmlService.createHtmlOutputFromFile("collectnames");
}
//End function doGet(e)
//URL of the Get AWF Names Spreadsheet:- https://docs.google.com/spreadsheets/d/1jFnBZ-kqGG7UzHS-VYkYu6ssy3uD5G5N0N2zc3wXQEg/edit#gid=0
function userClicked(awfname, realname, rbutton) {
//URL of AWF Spreadsheet
var urlAWF = "https://docs.google.com/spreadsheets/d/1jFnBZ-kqGG7UzHS-VYkYu6ssy3uD5G5N0N2zc3wXQEg/edit#gid=0";
var wsNameAWF = "AWFNames"
//Open Spreadsheet - Collect AWF Names
var ssAWF = SpreadsheetApp.openByUrl(urlAWF);
//Open Spreadsheet Page AWFNames
var wsAWF = ssAWF.getSheetByName(wsNameAWF);
wsAWF.appendRow([awfname, realname, rbutton, "AWF_SS", new Date()]);
//Test the Logging
Logger.log("ATH Test 12345");
}
//End function userClicked(awfname, realname, test)
<!DOCTYPE html>
<html>
<head>
<base target="_top">
<style>
h1 {
text-align: center;
}
p {
text-align: center;
}
div {
text-align: center;
}
form {
text-align: center;
}
</style>
</head>
<body>
<h1>Collect AWF Users Real Name!</h1>
<p>Please enter the name you are known by on AWF - (Your Handle)</p>
<form action="/action_page.php">
<label for="awfname">AWF Name:</label><br>
<input type="text" id="awfname" name="awfname"><br>
<p>Please enter your real name.</p>
<label for="realname">Real Name:</label><br>
<input type="text" id="realname" name="realname"><br><br>
<h1>Do you wish to hide your Real Name?</h1>
<label for="incog">Hide Real Name? </label>
<input type="radio" name="incog" value="Yes" checked="checked">Incognito</input>
<input type="radio" name="incog" value="No">Reveal my Name</input>
</form>
<h1>Press the button below to save your entry to the Google Sheet</h1>
<div class="flex-parent jc-center">
<button id="namebtn">------ Record Names ------</button>
</div>
<h1>Spreadsheet HERE:-</h1>
<p><a href="https://docs.google.com/spreadsheets/d/1jFnBZ-kqGG7UzHS-VYkYu6ssy3uD5G5N0N2zc3wXQEg/edit#gid=0" target="_blank">CLICK for
the "Collect AWF Names" Spreadsheet</a></p>
<script>
//Call the Button
document.getElementById("namebtn").addEventListener("click",doStuff);
function doStuff(){
//Pass the names from the Textboxes into the Variables
var awfname = document.getElementById("awfname").value;
var realname = document.getElementById("realname").value;
//Get Value of Checked Radio Button
var selectedRadioButton;
//Set the constant radioButtons to the Radio Button set named:- incog
const radioButtons = document.querySelectorAll('input[name="incog"]');
//find which Radio Button in the Collection of radioButtons is Checked
for (const radioButton of radioButtons) {
if (radioButton.checked) {
//Return Checked Buttons value
selectedRadioButton = radioButton.value;
break;
}
}
var temp;
temp = realname
//https://www.w3schools.com/js/js_if_else.asp
if (selectedRadioButton == "Yes") {
temp = "Hidden";
}
//google.script.run.userClicked(awfname, realname, "ATH Test");
google.script.run.userClicked(awfname, temp, selectedRadioButton);
//Set the textboxes to no value ""
document.getElementById("awfname").value = "";
document.getElementById("realname").value = "";
}
</script>
</body>
</html>
<!--END-->