Loading csv records into combobox
Posted: Fri Dec 06, 2019 8:31 am
I have a new page here : http://www.ourvilla.net.au/services.html
I need to load options into the Combobox from a csv file.
I need some help with a Javascrip function to do that
The Combobox id = Combobox1
The csv file is : mobiles.csv
The csv file has 4 columns :
Mobile Folder Village Log
I want the Village column [2] to be the one loaded. below is my current code - just missing that step:
<script>
// Read service providers data file
$(document).ready(function()
{
$.ajax({
type: "GET",
url: "mobiles.csv",
dataType: "text",
success: function(data) {processData(data);}
});
});
function processData(allText)
{
var allTextLines = allText.split(/\r\n|\n/);
var lines = [];
for (var i=0; i<allTextLines.length; i++)
{
var data = allTextLines.split(',');
var MobileNo = data[0];
var Folder = data[1];
var Village = data[2];
// The number here is hard coded, in real time, this will be passed into here
if(MobileNo == "0418344556")
{
// Load Village element into the Combobox
????
}
}
}
</script>
Any help will be appreciated
Cheers
I need to load options into the Combobox from a csv file.
I need some help with a Javascrip function to do that
The Combobox id = Combobox1
The csv file is : mobiles.csv
The csv file has 4 columns :
Mobile Folder Village Log
I want the Village column [2] to be the one loaded. below is my current code - just missing that step:
<script>
// Read service providers data file
$(document).ready(function()
{
$.ajax({
type: "GET",
url: "mobiles.csv",
dataType: "text",
success: function(data) {processData(data);}
});
});
function processData(allText)
{
var allTextLines = allText.split(/\r\n|\n/);
var lines = [];
for (var i=0; i<allTextLines.length; i++)
{
var data = allTextLines.split(',');
var MobileNo = data[0];
var Folder = data[1];
var Village = data[2];
// The number here is hard coded, in real time, this will be passed into here
if(MobileNo == "0418344556")
{
// Load Village element into the Combobox
????
}
}
}
</script>
Any help will be appreciated
Cheers