Hallo liebe User, noch ein gesundes neues Jahr
und zwar habe ich hier auch mal ein kleines Problem, hab hier 2 Seiten, bei beiden habe ich ein dropdown eingebunden von bootstrap. Auf der einen Seite wo alles in der php steht geht es einwandfrei. Bei der anderen Seite lade ich zusätzlich Daten von einem zweiten php Datei und da werden die im "Haupt"-PHP Datei eingebunden js scripte einfach nicht angewandet.
Kurz, würde ich das dropdown einfach in die cylinder_new.php schreiben wäre es alles schick, wird das dropdown aber aus der getdata.php geladen funktioniert es nicht.
HTML: cylinder_new.php
<!DOCTYPE html>
<?php require("dbconnect.php"); ?>
<html>
<head>
<link href="../css/nexus.css" rel="stylesheet">
<script type="text/javascript" src="../script/scripts.js"></script>
<script type="text/javascript" src="../script/jquery.min.js"></script>
<script type="text/javascript" src="../script/bootstrap.min.js"></script>
<script type="text/javascript" src="../script/bootstrap-select.min.js"></script>
</head>
<body onLoad="showData(this.value)">
<div id="body-bg">
<div id="content" class="bottom-border-shadow">
<div class="container background-white bottom-border">
<div class="row margin-vert-30-0">
<div class="col-md-12">
<div class="headline">
<h2 class="text-center">Überschrift</h2>
<hr class="kreis">
</div>
</div>
<div class="col-md-12">
<div class="col-md-11 margin-bottom-15">
<?php
$input_designname_new = mysqli_real_escape_string($mysqli, $_POST['input_designname_new']);
$input_walzensatznummer_new = mysqli_real_escape_string($mysqli, $_POST['input_walzensatznummer_new']);
....
mysqli_close($mysqli);
?>
</div>
</div>
<div class="col-md-12 margin-bottom-10">
<button class="btn btn-primary margin-bottom-5" type="submit" name="btn_search" onclick="toggleElementDisplay('search-box');">Suchfunktion einblenden</button>
<form>
<div id="search-box" style="display: none;">
<table>
<tr>
<th style="width:470px;" class="left">
Datensatz aus anderen Walzensatz laden
</th>
<th style="width:125px;">
</th>
<th style="width:370px; background-color: #ffffff;" class="">
</th>
<th style="width:25px; background-color: #ffffff;">
</th>
<th style="width:470px; background-color: #ffffff;" class="" colspan="4">
</th>
</tr>
<tr>
<td class="left">
Walzensatznummer
</td>
<td colspan="4"></td>
</tr>
<tr>
<td>
<div class="margin-5">
<div class="col-md-offset-0">
<input class="form-control" type="text" name="produktion" id="produktion" value="">
</div>
</div>
</td>
<td>
<div class="margin-5">
<div class="col-md-offset-0">
<button class="btn btn-primary margin-bottom-0" type="button" onclick="showData(this.value)" value=" ">Datensatz laden</button>
</div>
</div>
</td>
<td colspan="3" style="background-color: #ffffff;"></td>
</tr>
</table>
<hr class="margin-bottom-0 margin-top-10">
</div>
</form>
</div>
<div class="col-md-12">
<form class="" method="post">
<div id="txtHint"></div>
<button class="btn btn-primary margin-bottom-5 btn-fulsize" type="submit" name="btn_cylinder_new"><strong>Neue Walze anlegen</strong></button>
</form>
</div>
</div>
<hr class="margin-top-0">
<a href="#"><img class="myBack" src="../images/typo/top_arrow.png" alt="Seitenanfang"></a>
</div>
</div>
</div>
</body>
</html>
Alles anzeigen
PHP: getdata.php
<?php
require("dbconnect.php");
$q = $_GET['q'];
$sql="SELECT id, designname, produktionsnummer, walzensatznummer FROM db_walzenliste WHERE walzensatznummer = '".$q."'";
$result = mysqli_query($mysqli,$sql);
if (mysqli_num_rows ($result) > 0)
{
while($row = mysqli_fetch_array($result))
{
$test = $row['id'];
if($row['walzensatznummer'] == "")
{
echo "<table>
<tr>
<th colspan='6' class='left'>
Allgemeine Angaben
</th>
<tr>
...
<td style='width:300px;' class='left'>
<label>Format:</label>
<div class='margin-bottom-5'>
<div class='col-md-offset-0'>
<select class='selectpicker' data-show-subtext='true' data-live-search='true' name='input_format_new'>
<option value='' selected>Bitte auswählen ...</option>";
$sql="SELECT lz, format, kunde FROM db_format ORDER BY lz ASC, format ASC";
$result = mysqli_query($mysqli,$sql);
while($row = mysqli_fetch_array($result))
{
echo "<option data-subtext='".$row['kunde']."' value='".$row['format']."'>".$row['lz']." | ".$row['format']."</option>";
}
echo "</select>
</div>
</div>
</td>
...
</tr>
</table>";
}
}
}
mysqli_close($mysqli);
?>
Alles anzeigen
JavaScript: scripts.js
function showData(str)
{
if (str=="")
{
document.getElementById("txtHint").innerHTML="";
return;
}
if (window.XMLHttpRequest)
{
xmlhttp=new XMLHttpRequest();
}
else
{
xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
}
xmlhttp.onreadystatechange=function()
{
if (this.readyState==4 && this.status==200)
{
document.getElementById("txtHint").innerHTML=this.responseText;
}
}
var str = document.getElementById("produktion").value;
xmlhttp.open("GET","getdata.php?q="+str,true);
xmlhttp.send();
}
Alles anzeigen