Google App Script And Javascript: Accessing A Form Elements Inside Div Tags
I'd like to access an input element inside a form and a div. I'm new to Google app script and I believe I need to pass an argument that contains the DOM address from a JS function
Solution 1:
Issues:
- DOM Elements, except form element are not legal parameters to server side functions
Answer :
- Pass the form itself to server-side function, which will be converted to a form object.
Modified Code:
ClientSide:
<divclass="container"><formid ="myForm"><divclass="row"><divclass="col-25"><labelfor="location">Location</label></div><divclass="col-75"><inputtype="text"id="location"name="location_txt"placeholder="The location.."></div></div><divclass="row"><inputtype="button"onclick="update()"value="Update"></div></form><script>functionupdate()
{
google.script.run.selectCell(document.getElementById('myForm'));
alert("Success");//test message
}
</script>
Server-side:
functionselectCell(formObject)
{
var val0 = formObject['location_txt']
if (val0)
{
sheet.appendRow([val0]);
}
}
Post a Comment for "Google App Script And Javascript: Accessing A Form Elements Inside Div Tags"