How can I call div from JavaScript without them stacking on top of each other?
Here is the code for page 1:
<script>
function jvbab(content) {
var request = $.ajax({
type: "get",
url: "ceking.php",
data: {bab: content}
});
request.done( function( msg ) {
$("#myboxmin").html(msg);
});
request.fail(function(jqXHR, textStatus) {
alert( "Request failed: " + textStatus );
});
}
</script>
And here is the code for page 2:
<script>
function jvpasal(content) {
var request = $.ajax({
type: "get",
url: "cektopik.php",
data: {pasal: content}
});
request.done( function( msg ) {
$("#mybox").html(msg);
});
request.fail(function(jqXHR, textStatus) {
alert( "Request failed: " + textStatus );
});
}
</script>
When I run this code, the divs stack on top of each other like this:
<div id="myboxmin">
<div id="mybox">
</div>
</div>
I want to have these two divs separate like this:
<div id="myboxmin">
</div>
<div id="mybox">
</div>
Is there a solution to separate these divs? Thanks.
In my PHP file, I have included the following code:
<?php
session_start();
$bab = $_GET['bab'];
$_SESSION['bab']=$bab;
include '../koneksi.php';
?>
<html>
<head>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta name="keywords" content="" />
<meta name="description" content="" />
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>Klasifikasi Al-Quran</title>
<link href='http://fonts.googleapis.com/css?family=Oswald:400,300' rel='stylesheet' type='text/css' />
<link href='http://fonts.googleapis.com/css?family=Abel' rel='stylesheet' type='text/css' />
<script type="text/javascript" src="sitemapstyler.js"></script>
<link href="../css/default.css" rel="stylesheet" type="text/css" media="all" />
<link rel="stylesheet" href="../css/jquery-ui.css" />
<script>
function jvpasal(content) {
var request = $.ajax({
type: "get",
url: "cektopik.php",
data: {pasal: content}
});
request.done( function( msg ) {
$("#mybox").html(msg);
});
request.fail(function(jqXHR, textStatus) {
alert( "Request failed: " + textStatus );
});
}
</script>
</head>
<body>
<br><br><h1></h1><br><br>
<h3>Pasal</h3><br>
<?php
$r=mysql_query("SELECT DISTINCT id_pasal,nama_pasal FROM nama_pasal_topik
WHERE id_bab = '$bab' ") or die (mysql_error());
while($rr=mysql_fetch_array($r)){
$nama_pasal=$rr['nama_pasal'];
$id_pasal=$rr['id_pasal'];?>
<a href="#" id="pasal" name="pasal" onclick="jvpasal('<?php echo $id_pasal; ?>');" ><?php echo $nama_pasal; ?></a>
<br>
<?php } ?>
<div class="mybox">
m
</div> <!--tutup mybox-->
</body>
</html>