n'arrive pas a recuperer mes id pour effectuer une somme
bonjour,
j'aimerais recuperer les id du champ prix que j'arrive a afficher.Ceci pour en faire une somme, le probleme ce qu'il n'arrive pas a recup les id
serait ce parceque j'utilise des echo pour afficher executer les champs.
voici le code
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57
|
<?
require_once'ajax.php';
connect();
?>
<script type="text/javascript" language="javascript">
function calcule() {
ram_prix = document.getElementById('ram').value;
alert(ahahah);
ecran_prix = document.getElementById('ecran').value;
ecran2_prix = document.getElementById('ecran2').value;
cson_prix = document.getElementById('cson').value;
var le_total=0;
le_total = parseInt(ram_prix,10)+ parseInt(ecran_prix,10)+ parseInt(ecran2_prix,10)+parseInt(cson_prix,10);
document.getElementById('le_total').innerHTML = (isNaN(total))?"0":total;
document.getElementById('ram').innerHTML = (isNaN(total))?"0":ram_prix;
}
</script>
</head>
<body>
<form id="form" method="post" action="test2.php" >
<table border="0">
<tr>
<td><strong>Type</strong></td>
<td><strong>Produit</strong></td>
<td><strong>Prix</strong></td>
<td><strong>Description</strong></td>
</tr>
<tr>
<td>Ram </td>
<td><? include 'ram.php'?></td>
<!--<td><input type="text" onkeyup="ram.innerHTML=(1*this.value); calcule();" /></td>-->
</tr>
<tr>
<td><strong>total</strong></td>
<td></td>
<td id="total">0</td>
<td></td>
</tr>
<tr>
<td> </td>
<td></td>
<td></td>
<td><input type="submit" name="Submit" value="prendre en compte les modifications" /></td>
</tr>
</table>
</form> |
voici mon liste deroulante qui me permtes d'afficher le prix de mon choix
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67
|
<?php
////////////////////////////////////////////////////////////////
//declaration des variables
////////////////////////////////////////////////////////////////
//decalration des differentes ram
$var='2 giga';
$var1='3 giga';
$var2='4 giga';
// on crée la requête SQL
$table = 'conf_ram';
$sql = "SELECT * FROM $table WHERE nom='$var'";
// on envoie la requête
$req = mysql_query($sql) or die('Erreur SQL !<br>'.$sql.'<br>'.mysql_error());
// on fait une boucle qui va faire un tour pour chaque enregistrement
while($data = mysql_fetch_assoc($req))
{
// on affiche les informations de l'enregistrement en cours
echo '<form method="post" action="test2.php">';
echo '<select name="dd" size="1" id="ram" onChange="ram.value=('.def($var,$table).'); calcule();">
<option value="0"' ;
if(!isset($_POST['dd']) || $_POST['dd']==0 ){echo 'selected';}
echo '> '.$var. '</option>;
<option value="1"';
if(@$_POST['dd']==1){echo 'selected'; }
echo '>' .$var1. '</option>;
<option value="2"' ;
if(@$_POST['dd']==2){echo 'selected'; }
echo '>' .$var2. '</option>;';
}
echo '<td><input type="text" onchange="ram.value=(';
require_once 'ajax.php';
if(!isset($_POST['dd']) || $_POST['dd'] == 0){
echo '<td><input type="text" id="ram" value="';
prix($var,$table);
echo '" /></td>';
echo '<td>';
desc($var,$table);
}
if(@$_POST['dd'] == 1){
echo '<td><input type="text" id="ram" value="';
prix($var1,$table);
echo '" /></td>';
echo '<td>';
desc($var1,$table);
}
if(@$_POST['dd'] == 2){
echo '<td><input type="text" id="ram" value="';
prix($var2,$table);
echo '" /></td>';
echo '<td>';
desc($var2,$table);
}
echo '</td>';
?> |
pour voir ce que cela donne aller a l'adresse suivante
http://esigwald.free.fr/jsform/test2.php