Avatar
lawrence njoroge:15. May 15:21

anyone to assit me in some javascript please?

<!--main page content-->
<div class="col-md-8"> <!--loads the content dynamically from the database-->
<div class="row">
<h2 class="text-center">Featured Products</h2>
<?php while ($product = mysqli_fetch_as­soc($r)):?>
<div class="col-md-3">
<h4><?php echo $product['title'];?></h4>
<img src="<?php echo $product['ima­ge'];?>" alt="<?php echo $product['title'];?>" class="img-thumb"/>
<p class="list-price text-danger">list price: <s> Ksh<?php echo $product['lis­t_price'];?></s><­/p>
<p class="price">Our price:Ksh<?php echo $product['pri­ce'];?></p>
<button type="button" class="btn btn-success" onclick="deta­ilsmodal(<? $product['id']?>)"> Details</button>
</div>
<?php endwhile;?>
</div>

</div>

jquery

<script>

function detailsmodal(id){
var data = {id;
jQuery.ajax({

url: <?=BASEURL;?>+ 'includes/deta­ilsmodal.php',
method: "post",
data: data,
success: function(){
jQuery('body')­.append(data);
jQuery('#details-modal').modal('tog­gle');
},
error: function(){
alert("something went wrong");
}
});
}

</script>

Reply 15. May 15:21
where there is will there is a way
Avatar
IT Man
Member
Avatar
Replies to lawrence njoroge
IT Man:15. May 16:00

Please, use the button between a smiley and B - it's for a code. Paste your code again between the code tags, because now it's very unreadable. :)

Up Reply 15. May 16:00
Don't be silly, smile!
Avatar
Replies to IT Man
lawrence njoroge:15. May 16:07
<!--main page content-->
<div class="col-md-8"> <!--loads the content dynamically from the database-->
<div class="row">
<h2 class="text-center">Featured Products</h2>
<?php while ($product = mysqli_fetch_assoc($r)):?>
<div class="col-md-3">
<h4><?php echo $product['title'];?></h4>
<img src="<?php echo $product['image'];?>" alt="<?php echo $product['title'];?>" class="img-thumb"/>
<p class="list-price text-danger">list price: <s> Ksh<?php echo $product['list_price'];?></s></p>
<p class="price">Our price:Ksh<?php echo $product['price'];?></p>
<button type="button" class="btn btn-success" onclick="detailsmodal(<? $product['id']?>)"> Details</button>
</div>
<?php endwhile;?>
</div>

</div>

Javascript

<script>

function detailsmodal(id){
var data = {id;
jQuery.ajax({

url: <?=BASEURL;?>+ 'includes/detailsmodal.php',
method: "post",
data: data,
success: function(){
jQuery('body').append(data);
jQuery('#details-modal').modal('toggle');
},
error: function(){
alert("something went wrong");
}
});
}

</script>
Up Reply 15. May 16:07
where there is will there is a way
To maintain the quality of discussion, we only allow registered members to comment. Sign in. If you're new, Sign up, it's free.

3 messages from 3 displayed.