OK. In my wonderful world of not knowing what I am actually doing in programming, I have run across the following problem:
I am attempting to add a section to a Work Order page of my website. The purpose is for the user to select a part from a drop down list, the webpage does an AJAX call, returns the data needed to the same page without a refresh. (Basically adding parts used on a job to the page) I have tried every AJAX example that I could find across the web, with no avail. Most of them allow me to click the submit button and the page just sits there and stares at my blankly.
<tr><td><form id='Parts' action=''>Parts</td><td>";
echo "<select name='Part'>";
$mysqli = $conn;
$query= $mysqli->query("SELECT DISTINCT * FROM Parts");
while ($row = mysqli_fetch_array($query)) {
echo "<option value='" . $row['PartName'] . "'>" .$row['PartColor'] . " " .$row['PartName'] . "</option>";
} ;
echo "</td><td><input type='submit' name='AddPart' value='Add Part'></form></td></tr><tr><td>";
This is the base code that I am using on the page.
The php file that I have is:
<?php
if (isset($_POST['AddPart'])) {
$Part = $_POST['PartName'];
}
$sql = "SELECT * FROM Parts WHERE PartName = '$Part'";
$result = $conn->query($sql);
if ($result->num_rows > 0) {
echo "<table style='border-radius: 5px; color: white; position: absolute; left: 5%; top: 20%;'>";
while($row = $result->fetch_assoc()) {
echo "<tr><td><font color= '#EE9A00'>Qty</font></td><td width='10'></td><td><font color= '#EE9A00'>Part Name</font></td><td width='10'></td><td><font color= '#EE9A00'>Part Color</font></td><td width='10'></td><td><font color= '#EE9A00'>Part Description</font></td><td width='10'></td><td><font color= '#EE9A00'>Cost</font></td><td size='5'></td><td width='10'></td><td><font color= '#EE9A00'>Extended Cost</font></td></tr>
<tr><td><input type='number' style='width:50'></input></td><td></td><td>" . $row["PartName"]. "</td><td width='10'></td><td>" . $row["PartColor"]. "</td><td width='10'></td><td>" . $row["PartDescription"]. "</td><td width='10'></td><td>" . $row["BillPrice"]. "</td><td></td><td></td></tr>
</table>";
}
};
?>
What is the proper AJAX call to accomplish this? If it helps, I am using mySQL through Yahoo websites.