Answer the question
In order to leave comments, you need to log in
Error in jS When importing csv into mysql database?
I decided to use a ready-made script for importing csv into mysql,
but in one of the files it gives an error
TypeError: combo3.attachEvent is not a function
dviglo-shop.loc/csv_importer/includes/javascript/s...
Line 82
function CreateForm_existing() {
doc.form1.stage.value = "import_setup";
// Empty workarea
EmptyWorkarea(div);
var workarea = doc.getElementById(div);
// Declare vars
var freeVar;
var i;
var a_href;
var table = _table.cloneNode(true); // Create table
var tbody = _tbody.cloneNode(false); // Create tbody
var row1 = _tr.cloneNode(false); // Row for database
var cell11 = _td.cloneNode(false); // Cell for words
var cell12 = _td.cloneNode(false); // Cell for combo
var text1 = doc.createTextNode("Select database: ");
var combo3 = _select.cloneNode(false); // SELECT control for database
combo3.setAttribute("name", "dvigloshop");
combo3.attachEvent("onchange", GetTables);
combo3.options[combo3.length] = new Option("Select database", ""); // Add "Select database option"
for (i = 0; i < mysqlDatabaseArray.length; i++) {
combo3.options[combo3.length] = new Option(mysqlDatabaseArray[i], mysqlDatabaseArray[i]); // Add databases to options of SELECT control
}
row2 = _tr.cloneNode(false); // Row for tables
cell21 = _td.cloneNode(false); // Cell for word
cell22 = _td.cloneNode(false); // Cell for combo
var text2 = doc.createTextNode("Select table: ");
var combo2 = _select.cloneNode(false); // SELECT control for tables
combo2.setAttribute("name", "dbTableName");
workarea.appendChild(table);
table.appendChild(tbody);
tbody.appendChild(row1);
row1.appendChild(cell11);
cell11.appendChild(text1);
row1.appendChild(cell12);
cell12.appendChild(combo3);
tbody.appendChild(row2);
row2.appendChild(cell21);
cell21.appendChild(text2);
row2.appendChild(cell22);
cell22.appendChild(combo2);
combo3.focus();
}
function GetTables() {
var cmbTable = FieldSearch(doc.form1, "dbTableName");
var cmbDatabase = FieldSearch(doc.form1, "dbName");
var db = cmbDatabase.value;
for (i = cmbTable.length; i >= 0; i--) {
cmbTable.options[i] = null;
}
cmbTable.options[0] = new Option("Select table", "");
for (i = 0; i < mysqlTableArray[db].length; i++) {
cmbTable.options[(i+1)] = new Option(mysqlTableArray[db][i], mysqlTableArray[db][i]);
}
cmbTable.focus();
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question