• 1

Read this first!

We do not monitor these forums. The forum is provided to exchange information and experience with other users ONLY. Forum responses are not guaranteed.

However, please submit a ticket if you have an active subscription and wish to receive support. Our ticketing system is the only way of getting in touch with RSJoomla! and receiving the official RSJoomla! Customer Support.

For more information, the Support Policy is located here.

Thank you!

TOPIC: Populate Drop Drown Options from Google Sheet?

Populate Drop Drown Options from Google Sheet? 1 year 5 months ago #43059

  • contact13
  • contact13's Avatar
  • OFFLINE
  • Junior Boarder
  • Posts: 30
  • Thank you received: 5
I'm familiar with how to auto-populate the options in a dropdown list from a table, but I was wondering if it's possible to do the same with with the cell values from a Google Sheet column. For instance, if my Google Sheet has a list of names in Column A, can I bring those in as values in a drop-down field?

If so- how?
The administrator has disabled public write access.

Populate Drop Drown Options from Google Sheet? 1 year 4 months ago #43135

  • contact13
  • contact13's Avatar
  • OFFLINE
  • Junior Boarder
  • Posts: 30
  • Thank you received: 5
Bumping this. Anyone?
The administrator has disabled public write access.

Populate Drop Drown Options from Google Sheet? 1 year 4 months ago #43149

  • iceferret
  • iceferret's Avatar
  • OFFLINE
  • Gold Boarder
  • Posts: 246
  • Thank you received: 64
Never done it but from what I understand you would use a combination of javascript and PHP (or whatever you're familiar with) to populate the dropdown, simple example below

The form html
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Dropdown from Spreadsheet</title>
</head>
<body>
 
    <form>
        <label for="dropdown">Select Option:</label>
        <select id="dropdown" name="dropdown"></select>
    </form>
 
    <script src="script.js"></script>
</body>
</html>

Javascript.....
document.addEventListener('DOMContentLoaded', function () {
    // Fetch data from the server (PHP in this example)
    fetch('getData.php')
        .then(response => response.json())
        .then(data => {
            // Populate dropdown with data
            const dropdown = document.getElementById('dropdown');
            data.forEach(option => {
                const optionElement = document.createElement('option');
                optionElement.value = option.value;
                optionElement.textContent = option.label;
                dropdown.appendChild(optionElement);
            });
        })
        .catch(error => console.error('Error fetching data:', error));
});

and the PHP.........
<?php
 
// Assuming your spreadsheet data is in a CSV file named 'data.csv'
$csvFile = 'data.csv';
 
// Read CSV file and convert it to a JSON array
$rows = array_map('str_getcsv', file($csvFile));
$headers = array_shift($rows);
$data = array();
foreach ($rows as $row) {
    $data[] = array_combine($headers, $row);
}
 
// Convert data to JSON and send it to the client
header('Content-Type: application/json');
echo json_encode($data);
If you can keep your head when all about you are losing theirs, then you obviously don't understand the situation!
The administrator has disabled public write access.
  • 1

Read this first!

We do not monitor these forums. The forum is provided to exchange information and experience with other users ONLY. Forum responses are not guaranteed.

However, please submit a ticket if you have an active subscription and wish to receive support. Our ticketing system is the only way of getting in touch with RSJoomla! and receiving the official RSJoomla! Customer Support.

For more information, the Support Policy is located here.

Thank you!