I need to select one cell then get this cells value and put to sidebar textbox area and on press submit button put this text to same selected cell.
So i have sidebar html
<div>
<script>
function updateUrl(vals,range) {
var div = document.getElementById('myTextarea');
div.value = vals.vals ;
}
</script>
<form id="myForm">
<input type="button" value="Select" onclick="google.script.run
.withSuccessHandler(updateUrl)
.getData1()" />
<input onclick="google.script.run.getValuesFromEditor(document.forms[0])" type="button" value="Submit" /><input type="button" value="Close" onclick="google.script.host.close()" /><br/>
<textarea style="border: none; width: 100%; height: 100%; box-sizing: border-box;-ms-box-sizing: border-box;-webkit-box-sizing: border-box;overflow: hidden;position: absolute;" wrap="hard" name="myTextarea" id="myTextarea"></textarea>
</form>
</div>
in script.gs
function getValuesFromEditor(editor){
var rowData = editor.myTextarea;
range.setValues(rowData);
}
function getData1() {
var ss = SpreadsheetApp.getActiveSpreadsheet();
var sheet = ss.getSheets()[0];
var range = sheet.getActiveCell();
var vals = range.getValue();
return {vals:vals,range:range};
};
But i cant get selected cell range it always put as undefined. So how to put to the same selected range from there textarea was filled. Because it posible to put cell value to text area and then change selection but i want to prevent this so data must be posted in same cell from which are taken value.
In other words if value taked form A1 cell to text area then if press submit button changed text must be placed only to A1 cell not in activecell as selection can be changed while submit button will be pressed.