Help Select 2 drop-down lists to get information from a column in my spreadsheet

I'm designing a warehouse app, and since I'm new, I have a lot of questions. I want the information to come from a Google Spreadsheet consisting of two columns (Warehouse, Kilograms). The first column is composed of two elements: the Warehouse and the Filling Tank, and the second column contains the Kilograms.

In the app, the Source Tank selection consists of two drop-down menus where I first select the warehouse and then the tank. I would like it to show me the kilos from my spreadsheet corresponding to the selected tank when I select both in the text field below.


See here for an example:

1 Like

Do want help with script url and gviz method of query? Both are possible

Yes i need more help

Yes, i need more help

Which method you want gviz query or script url query? Are you using spreadsheet extension or script url method of GET and POST request?

Based on your existing method we would like to help you

URL script

function doGet(e) {
  const sheet = SpreadsheetApp.getActiveSpreadsheet().getActiveSheet();
  const inputCode = e.parameter.salesCode; // Receive the sales code from the request
  let result = "No match found"; // Default message if no match is found

  // Get all data in the sheet (assuming data starts from the first row)
  const data = sheet.getDataRange().getValues();

  // Look for a matching code in column A
  for (let i = 0; i < data.length; i++) {
    if (data[i][0].trim() === inputCode.trim()) { // Check for match
      result = data[i][1]; // Get value from column B of the matched row
      break; // Stop after finding the first match
    }
  }

  // Return the result (either the found value or the default message)
  return ContentService.createTextOutput(result);
}

Add this code, deploy it. And design when to trigger..

If bith droodown vakue is selected then set web url to script url+?+salescode=join dropdown 1 selected val + one space + drop-down 2 selected valu
GET request

When web got request
Set textbox text = getresponsecontent after checking it is not No Matching found