Hallo Gemeinshcaft,
möchte gerne ein arcordeon script in mein echo code eingebunden haben - leider funzt das script nicht so - binde ich es in eine neue html seite ein - dann klappt es mit dem aufklappen
das ist das original - ich habe das javascript und das css richtig eingebunden
möchte gerne ein arcordeon script in mein echo code eingebunden haben - leider funzt das script nicht so - binde ich es in eine neue html seite ein - dann klappt es mit dem aufklappen
PHP-Code:
<?php echo ' <tr>
<td width="10"> </td>
<td>
<span style="text-decoration:underline;" class="tooltip" title="Kabinenbild|<img src=\''.$pri->Name.'\'>">'.$pri->Name.'</span>
<span><p align="left">'.$searchResult['Ship']['ShipID'].'-'.$pri->CabinTypeID .'-'.$cabinDescription.'</p></span>
</td>
<td width="10"></td>
<td width="150"><strong></strong>
<strong>'.$priceText.'</strong> ' //Hier fängt es an das arcordeon script
?>
<button class="accordion">Section 1</button>
<div class="panel">
<p>Lorem ipsum...</p>
</div>
<?php '
</td>
<td width="10"> </td>
<td width="180"><strong>
'.(!$soldout ? '<a href="buchung.php?price='.$pri->PriceID.'&cabincode='.$pri->Code.'&trip='.$tripid.'&adults='.($model['reisendeErwachsene']['userValue'] ?: $model['reisendeErwachsene']['defaultValue']).'&kids='.($model['reisendeKinder']['userValue'] ?: $model['reisendeKinder']['defaultValue']).'&routeid='.$_GET["routeid"].'">Zum Buchungsformular</a>':'-').'
</strong></td>
</tr>
';
PHP-Code:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<style>
/* Style the buttons that are used to open and close the accordion panel */
.accordion {
background-color: #eee;
color: #444;
cursor: pointer;
padding: 18px;
width: 100%;
text-align: left;
border: none;
outline: none;
transition: 0.4s;
}
/* Add a background color to the button if it is clicked on (add the .active class with JS), and when you move the mouse over it (hover) */
.active, .accordion:hover {
background-color: #ccc;
}
/* Style the accordion panel. Note: hidden by default */
.panel {
padding: 0 18px;
background-color: white;
display: none;
overflow: hidden;
}
</style>
<title>Unbenanntes Dokument</title>
</head>
<body>
<button class="accordion">Section 1</button>
<div class="panel">
<p>Lorem ipsum...</p>
</div>
<button class="accordion">Section 2</button>
<div class="panel">
<p>Lorem ipsum...</p>
</div>
<button class="accordion">Section 3</button>
<div class="panel">
<p>Lorem ipsum...</p>
</div></body>
<script>
var acc = document.getElementsByClassName("accordion");
var i;
for (i = 0; i < acc.length; i++) {
acc[i].addEventListener("click", function() {
/* Toggle between adding and removing the "active" class,
to highlight the button that controls the panel */
this.classList.toggle("active");
/* Toggle between hiding and showing the active panel */
var panel = this.nextElementSibling;
if (panel.style.display === "block") {
panel.style.display = "none";
} else {
panel.style.display = "block";
}
});
}
</script>
</html>
Kommentar