Disclaimer: I've tried to look at other examples, but every one of them is using .php, my class is not. I'm trying to take the values from my MySQL server and insert them into my html code. I cannot use .php.
Here is an example of my script inside html:
<script>
console.log("first script test");
function processForm() {
let sqlStmt = "";
sqlStmt = "SELECT * FROM `Product-Service`";
sqlCost = "Select cost FROM `Product-Service`";
sqlName = "Select name FROM `Product-Service`";
sqlDesc = "Select description FROM `Product-Service`";
console.log("2nd script test");
MySql.Execute(
"host",
"user",
"pw",
"db",
sqlDesc,
function (data) {
document.getElementById("output").innerHTML = data;
//console.log("data parameter: " + data);
var dataAsString = JSON.stringify(data);
document.getElementById("output").innerHTML = dataAsString;
//console.log("Single row as obj: " + data.Result[0]);
console.log("Single row as string: " + JSON.stringify(data.Result[0]));
//console.log("Single row, single column: " + data.Result[0].name);
document.getElementById("basic").innerHTML = JSON.stringify(data.Result[0]);
console.log(data.Result[0])
document.getElementById("intermediate").innerHTML = JSON.stringify(data.Result[1]);
document.getElementById("advanced").innerHTML = JSON.stringify(data.Result[2]);
}
);
}
</script>
And I'm trying to have 1 dropdown box with 3 options:
<div class="output" onload="processForm()">
<h2><u>Products and Services</u></h2>
<h4><select>
<!-- <input type="button" value="test button" onclick="processForm()"> -->
<p>Car Detailing options</p>
<option onclick="" value="basic">Basic</option>
<option value="intermediate">Intermediate</option>
<option value="advanced">Advanced</option>
</select>
<p>Description: </p>
<p></p>
<p></p>
<p></p>
</h4>
</div>
Using the above script I can already get the items from the database to display on the page, but I'm having trouble getting them into the option box (I just hardcoded it) as well as populating the <p>Description: </p>
with the description every time the dropdown box changes.
Appreciate any help.
<script>
tags.