Buenas noches soy bastente nuevo en PHP y he creado una función para calcular cuotas con un select pero cuando selecciono una cuota para ver el resultado del lado del cliente, en el navegador, se refresca todo. Al archivo que calcula las cuotas lo llamo con la función "include" Podrian ayudarme porfa?
[URL="http://ceccanaan.org/interna/interna2.php"]http://ceccanaan.org/interna/interna2.php[/URL]
archivo: interna2.php
Código PHP:
<?php include 'cuotero.php'; ?>
el otro archivo php, que incluyo en interna2.php
cuotero.php:
Código PHP:
<?php
$moneda = Gs;
$rcs_financiera = 7;
$row_rcs_financiera = 7;
$totalRows_rcs_financiera = 2;
$cuotaPorDefecto = 24;
$price = 12000000;
$_GET['precio_contado'] = 12000000;
//echo $ggg."<br/>";
//echo $price."<br/>";
$cuotaSeleccionada = $_GET['cuotaSeleccionada'];
function puntos($s)
{
$s= str_replace('"','', $s);
$s= str_replace(':','', $s);
$s= str_replace('.','', $s);
$s= str_replace(',','', $s);
$s= str_replace(';','', $s);
$s= str_replace('Gs','', $s);
return $s;
}
//$price = puntos('price');
if(!isset($_GET['cuotaSeleccionada'])){$cuotaSeleccionada = $cuotaPorDefecto; $_GET['cuotaSeleccionada'] = $cuotaPorDefecto;}
//setcookie( 'price' , $price , time()+3600, '/' );
//porcentaje gasto administrativo sobre el valor contado
$valor_gasto_administrativo = 0;
$ga_precio_contado = $price*$valor_gasto_administrativo/100;
$monto_total_prestamo= $price +$ga_precio_contado;
//porcentaje de interes segun financiera
$tasa=2;
$totalRows_rcs_porcentaje_interes = 4;
$cuotasTotales = 24;
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="es">
<head>
<title></title>
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<link href="cuotero.css" rel="stylesheet" type="text/css" />
<style type="text/css">
#node1
{
float: left;
width: 155px;
}
#node2
{
float: left;
margin-top: 5px;
margin-left: 0px;
}
.Estilo2 {font-family: Arial, Helvetica, sans-serif}
.Estilo3 {font-weight: bold}
.Estilo4 {font-family: Arial, Helvetica, sans-serif; font-weight: bold; }
.cuadro {
float: right;
}
select {
width: 100px;
padding:3px;
margin: 0;
-webkit-border-radius:4px;
-moz-border-radius:4px;
border-radius:4px;
-webkit-box-shadow: 0 3px 0 #ccc, 0 -1px #fff inset;
-moz-box-shadow: 0 3px 0 #ccc, 0 -1px #fff inset;
box-shadow: 0 3px 0 #ccc, 0 -1px #fff inset;
background: #f8f8f8;
color:#888;
border:none;
outline:none;
display: inline-block;
-webkit-appearance:none;
-moz-appearance:none;
appearance:none;
cursor:pointer;
}
label {position:relative}
label:after {
content:'<>';
font:11px "Consolas", monospace;
color:#aaa;
-webkit-transform:rotate(90deg);
-moz-transform:rotate(90deg);
-ms-transform:rotate(90deg);
transform:rotate(90deg);
right:8px; top:2px;
padding:0 0 2px;
border-bottom:1px solid #ddd;
position:absolute;
pointer-events:none;
}
label:before {
content:'';
right:6px; top:0px;
width:20px; height:20px;
background:#f8f8f8;
position:absolute;}
/* Targetting Webkit browsers only. FF will show the dropdown arrow with so much padding. */
@media screen and (-webkit-min-device-pixel-ratio:0) {
select {padding-right:18px}
}
</style>
</head>
<body>
<div class="cuadro">
<div id="node2"><form method="get" enctype="multipart/form-data" class="cuotero" id="cuotas" align="left">
<label>
<select name="cuotaSeleccionada" onchange="this.form.submit()">
<? for($i=2; $i <= 24; $i++){?>
<option value="<?=$i?>" <? if($i == $_GET['cuotaSeleccionada']){echo "selected";}?>>
<?=$i?>
</option>
<? } ?>
</select></label> cuotas de:
</form>
<?php if ($tasa > 0) { // Show if recordset not empty ?>
<p style="display:none" align="center" class="Estilo2">Precio Contado: <span class="Estilo4"><?php echo number_format($_GET['precio_contado'], 0, '', '.' ); ?> Gs.</span> | Gasto Administrativo: <?php echo number_format($ga_precio_contado, 0, '', '.' ); ?> Gs. | Financiera: <?php echo "4%"; ?></p>
<p style="display:none" align="center" class="Estilo3">MONTO DEL PRESTAMO: <?php echo number_format($monto_total_prestamo, 0, '', '.' ); ?> Gs. </p>
<?php } ?>
<?php if ($totalRows_rcs_porcentaje_interes > 0) { // Show if recordset not empty ?>
<?php } ?>
</div><!-- #node2 end -->
<div id="node1"><div align="left" style="font-size:20px; color:#FFFFFF; ; ; ; background-color: #006600; background-image: url(../../image/price-tag.png); background-repeat: no-repeat; background-position: left; ">
<table width="76%" border="0" align="center">
<tr>
<td width="20%"> <span class="Estilo4">₲</span></td>
<td width="80%">
<div align="center" class="Estilo4">
<?php
// se generan las cuotas a pagar con sus correspondientes detalles
echo '<table class="table">';
echo '<tr>';
echo '<td align="right">';
echo '';
echo '<br>';
echo '';
echo '</td>';
$cantCuotas = 0;
do {
if ($tasa<=0) {
$monto_cuota = round(($monto_total_prestamo/$cantCuotas), 0);
}
if ($tasa>0) {
$anual = $tasa/100;
$mes = round(($anual/12), 6);
$monto_cuota = $monto_total_prestamo / ((pow((1+$mes), $cantCuotas)-1)/($mes*pow((1+$mes),$cantCuotas)));
}
if($cantCuotas == $cuotaSeleccionada){
echo '<td align="right">';
echo number_format($monto_cuota, 0, '', '.' );
echo '</td>';
}
$cantCuotas ++;
} while ($cantCuotas >= 0 and $cantCuotas <= $cuotasTotales );
echo'</tr>';
echo '</table>';
?>
</div></td>
</table>
<p align="center"> </p>
</div></div></div><!-- #node1 end -->
</body>
</html>