Shanmugam Arumugam
Shanmugam Arumugam

Reputation: 25

Need support on new button click to open a URL - pass a document variable value as parameter

Upload file spreadsheet dataData record

I have copied and created the app from the following website.

https://www.bpwebs.com/crud-operations-on-google-sheets-with-online-forms/

Now I want to add a button (which I did) but unable to make it work.

On click on this new button (named "Upload Files"- submit fires.... I want the following to happen when user click this button

-- Should not fire submit -- should open a new window and open url with a parameter. -- URL = "https://www.google.com" -- parameter is the recid - let us assume recid has value 100046 -- dynamically generated URL -- to execute on click of this button would be "https://www.google.com?id=100046"

I am completely new to google sheets and app script. So bear with me for naïve. Please can anyone help me with this. Thanks to the SO community for making people life easier.

Upvotes: 0

Views: 81

Answers (1)

idfurw
idfurw

Reputation: 5852

Maybe you are looking for:


const url = 'https://script.google.com/macros/s/AKfycbwyTJsFDgeboCt3jcyKI6KQtZ6svIHPynaStM9AwvzCgCFmbds/exec';
const form = document.forms[0];
form.addEventListener('submit', function(e) {
  e.preventDefault();
  window.open(url + '?recid=' + form.recid.value);
});

Upvotes: 1

Related Questions