I have a page which uses jquery to put a picture in a select box, it also uses bootstrap so I think the two scripts are causing a problem
The problem seems to be it doesn’t see the function (select2)
But when I comment out the three bootstap scripts, it seems to work
The scripts I have are
<?php
session_start();
if(isset($_SESSION['email'])) {
include "../conn.php";
$power_strip_id = (int)$_GET['id'];
$sql = 'SELECT power_strips.pdu_id,power_strips.name,power_strips.manufacturer,power_strips.model,power_strips.room_id,power_strips.row,power_strips.bay,
power_strips.receptical_type,power_strips.total_recepticals,power_strips.voltage,power_strips.notes,power_strips.enabled,
pdus.name AS pdu_name, pdus.pdu_id
FROM power_strips
INNER JOIN pdus ON power_strips.pdu_id = pdus.pdu_id
WHERE power_strip_id = '.$power_strip_id;
//echo $sql;
$result = mysqli_query($conn, $sql);
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta http-equiv="refresh" content="1800;url=../logout.php" />
<title>Edit PDU</title>
<link rel="stylesheet" type="text/css" href="../css/bootstrap.min.css">
<link rel="stylesheet" href="../css/font-awesome.min.css" type="text/css" />
<link rel="stylesheet" type="text/css" href="../css/tabs.css">
<link rel="stylesheet" href="../css/style.css" type="text/css" />
<link href='../css/select2.min.css' rel='stylesheet' type='text/css' / >
</head>
<body>
<script src='../scripts/jquery-3.0.0.js' type='text/javascript'></script>
<!-- select2 script -->
<script src='../scripts/select2.min.js'></script>
<script>
$(document).ready(function(){
$("#r_type").select2({
templateResult: formatOptions
});
$("#p_type").select2({
templateResult: formatOptions
});});
function formatOptions (state) {
if (!state.id) { return state.text; }
console.log(state.element.value);
var $state = $(
'<span ><img sytle="display: inline-block" class="type" src="../images/' + state.element.value.toLowerCase() + '.png" /> ' + state.text + '</span>'
);
return $state;
}
</script>
<!--<script src="../scripts/jquery-3.3.1.slim.min.js"></script>
<script src="../scripts/popper.min.js"></script>
<script src="../scripts/bootstrap.min.js"></script>-->
</body>
</html>