Hallo,
Ik ben bezig met een systeem waar mee dingen kan bestellen. En als iets besteld dan moet bij elke product de pagina refreshen en daardoor gaat die weer helemaal naar boven van de pagina. Hoe kan je het zo maken dat dat niet zo gebeurd en dat het werk op pc en smartphone.
Dit is de code van de pagina.
Heb even 2 keer php omdat dan de code dan beter word weergeven want er ook script in staat.
<?php
<?php
include_once("config.php");
$page_name = "Bestelformulier";
$bestel1= "class='active'";
include("top3.php");
include("includes/db.php");
include("includes/functions.php");
if($_REQUEST['command']=='delete' && $_REQUEST['pid']>0){
remove_product($_REQUEST['pid']);
}
else if($_REQUEST['command']=='clear'){
unset($_SESSION['cart']);
}
else if($_REQUEST['command']=='update'){
$max=count($_SESSION['cart']);
for($i=0;$i<$max;$i++){
$pid=$_SESSION['cart'][$i]['productid'];
$q=intval($_REQUEST['product'.$pid]);
if($q>0 && $q<=999){
$_SESSION['cart'][$i]['qty']=$q;
}
else{
$msg='Some proudcts not updated!, quantity must be a number between 1 and 999';
}
}
}
if($_REQUEST['command']=='add' && $_REQUEST['productid']>0){
$pid=$_REQUEST['productid'];
addtocart($pid,1);
header("location:Bestel.php");
//header("location:load.php");
exit();
}
?>
<script language="javascript">
function addtocart(pid){
document.form1.productid.value=pid;
document.form1.command.value='add';
document.form1.submit();
}
</script>
<script language="javascript">
function del(pid){
if(confirm('Wil je echt dit product uit je Winkelwagen halen?')){
document.form1.pid.value=pid;
document.form1.command.value='delete';
document.form1.submit();
}
}
function clear_cart(){
if(confirm('Wil echt heel je Winkelwagen leeg halen?')){
document.form1.command.value='clear';
document.form1.submit();
}
}
function update_cart(){
document.form1.command.value='update';
document.form1.submit();
}
function verstuur_cart(){
document.form1.command.value='update';
document.form1.submit();
window.location='billing.php';
}
</script>
<form name="form1">
<input type="hidden" name="productid" />
<input type="hidden" name="command" />
</form>
<div class="page-header">
<h1><span class="glyphicon glyphicon-pencil"></span> Bestelformulier</h1>
</div>
<div id="myTabs" class="tab-content">
<div class="tab-pane fade in active" id="hs">
<?php include("HS.php")?>
</div>
<div class="tab-pane fade" id="verband">
<?php include("verbandmiddelen.php")?>
</div>
<div class="tab-pane fade" id="kantoor">
<?php include("kantoor.php")?>
</div>
</div>
<?php include('bottom.php') ?> ?>
1.539 views