begin process at 2012 05 29 02:01:08
  Trouver un code source :
 
dans
 
Accueil > Forum > 

Javascript / DHTML / Ajax

 > 

CSS

 > 

Général

 > 

checkbox plus prix


Derniers messages déposésPoser une question dans le forum ou lancer une discussion

checkbox plus prix

samedi 20 novembre 2010 à 21:25:30 | checkbox plus prix

gfpl

Bonjour,

voila j'explique mon problème

j'ai ai total 6 checkbox plus 3 retour sur div(affiche un texte ) si on click sur tel ou tel check box

la structure est simple

j'ai 3 chekbox principal produit 1, produit 2, produit 3

2 check box secondaire option 1 option 2

mon principe qui fonctionne est le suivant si on click su le produit 1 on peut cocher l'option 1 & 2
pareil pour 2

mais pour le 3 les option 1 & 2 sont alors cocher et désactiver


mon problème réside ensuite est que je veut afficher un prix dans un autre div

si on coche le produit 1 & option 2 je doit afficher un prix dans un div

je bloque sur le prix le reste fonctionne bien .. si qq a une solution ?


ce qui marche pas :
Code Javascript :
<script type="text/javascript" language="JavaScript">
function traitement_check()
{
     
     if (achat.checked == true; )
     {
         ref=document.getElementById("prix_f");
    ref.innerHTML='<span style="color:#C5281f; font-size:14px">Inclus</span>';
     
     }else{
     ref=document.getElementById("prix_f");
    ref.innerHTML='ggggg';
     }
     }
     </script>





voici le code de base ( ce qui marche excepter le div -> prix_f

Code Javascript :
<script type="text/javascript" language="JavaScript">
function Chkbox(id){
    switch(id){
        case "starter" :
            document.getElementById("starter").checked = true;
            document.getElementById("pro").checked = false;
            document.getElementById("premium").checked = false;
            document.getElementById("help_desk").disabled=false;
            
            document.getElementById("buy_at_end").disabled=false;
            
            ref=document.getElementById("starter_txt");
    ref.innerHTML='&#8364; <span style="color:#C5281f; font-size:14px">10</span><span style="color:#545252; font-size:14px">,</span><span style="color:#C5281f; font-size:14px">99</span>/mois';
    
    ref=document.getElementById("buy_at_end_txt");
    ref.innerHTML='&#8364; <span style="color:#C5281f; font-size:14px">4</span><span style="color:#545252; font-size:14px">,</span><span style="color:#C5281f; font-size:14px">99</span>/mois';

            
        break;
        case "pro" :
            document.getElementById("starter").checked = false;
            document.getElementById("pro").checked = true;
            document.getElementById("premium").checked = false;
            document.getElementById("help_desk").disabled=false;
            ref=document.getElementById("starter_txt");
            
            document.getElementById("buy_at_end").disabled=false;
            
    ref.innerHTML='&#8364; <span style="color:#C5281f; font-size:14px">10</span><span style="color:#545252; font-size:14px">,</span><span style="color:#C5281f; font-size:14px">99</span>/mois';
    
    ref=document.getElementById("buy_at_end_txt");
    ref.innerHTML='&#8364; <span style="color:#C5281f; font-size:14px">4</span><span style="color:#545252; font-size:14px">,</span><span style="color:#C5281f; font-size:14px">99</span>/mois';
        break;
        
        case "premium" :
            document.getElementById("starter").checked = false;
            document.getElementById("pro").checked = false;
            document.getElementById("premium").checked = true;
            document.getElementById("help_desk").checked = true;
            document.getElementById("help_desk").disabled=true;
            
            document.getElementById("buy_at_end").checked = true;
            document.getElementById("buy_at_end").disabled=true;
            
            ref=document.getElementById("starter_txt");
    ref.innerHTML='<span style="color:#C5281f; font-size:14px">Inclus</span>';
    
    ref=document.getElementById("buy_at_end_txt");
    ref.innerHTML='<span style="color:#C5281f; font-size:14px">Inclus</span>';
        break;
        
        
    }
}

   </script>


Code HTML :
<form id="form1" name="form1" method="post" action="add_services.php">
        <table width="698" height="301" border="0">
          <tr>
            <td width="340" height="151" valign="top"><!-- left !-->
              
              <table height="139" border="0" cellpadding="0" cellspacing="0" style="margin-top:12px">
                <tr>
                  <td width="66">&nbsp;</td>
                  <td width="266" valign="top"><table width="260" height="134">
                      <tr>

                        <td height="14"><b style=" color:#545252; margin-left:30px;">E-commerce</b></td>
                      </tr>
                      <tr>
                        <td height="99" valign="top"><div style="position:absolute; margin-left:153px; width: 118px;"><span style="margin-left:0px;float:right; margin-right:20px; margin-top:-7px">Choix du type</span></div>
                          <br/>
                          <div style="margin-left:40px; margin-top:6px;">
                            <table width="201" height="25" border="0" cellpadding="0" cellspacing="0" style="font-size:10px; font-family:Arial, Helvetica, sans-serif">
                              <tr>

                                <td width="37" align="center"><input name="la" value="E-commerce Starter" type="checkbox" id="starter"  onclick="Chkbox(this.id);"></td>
                                <td width="84" align="center"><img src="images/starter.png" width="78" height="25"></td>
                                <td width="146" align="right">&#8364; <span style="color:#C5281f; font-size:14px">179</span><span style="color:#545252; font-size:14px">,</span><span style="color:#C5281f; font-size:14px">99</span>/mois</td>
                              </tr>
                            </table>
                           <!-- NEXT !-->

                            <table width="201" height="25" border="0" cellpadding="0" cellspacing="0" style="font-size:10px; font-family:Arial, Helvetica, sans-serif; margin-top:5px">
                              <tr>
                                <td width="37" align="center"><input type="checkbox" value="E-commerce Pro" name="la" id="pro"  onclick="Chkbox(this.id);"></td>
                                <td width="84" align="center"><img src="images/pro.png" width="78" height="25"></td>
                                <td width="146" align="right">&#8364; <span style="color:#C5281f; font-size:14px">217</span><span style="color:#545252; font-size:14px">,</span><span style="color:#C5281f; font-size:14px">99</span>/mois</td>
                              </tr>

                            </table>
                      <!-- ON THE NEXT -->
                  <table width="201" height="25" border="0" cellpadding="0" cellspacing="0" style="font-size:10px; font-family:Arial, Helvetica, sans-serif; margin-top:5px">
                              <tr>
                                <td width="37" align="center"><input type="checkbox" value="E-commerce Premium" name="la" id="premium" onclick="Chkbox(this.id);"></td>
                                <td width="84" align="center"><img src="images/premium.png" width="78" height="25"></td>
                                <td width="146" align="right">&#8364; <span style="color:#C5281f; font-size:14px">387</span><span style="color:#545252; font-size:14px">,</span><span style="color:#C5281f; font-size:14px">99</span>/mois</td>

                              </tr>
                            </table>
                          </div></td>
                      </tr>
                    </table></td>
                </tr>
              </table>
              
              <!-- NO MADE !-->
              <table height="139" border="0" cellpadding="0" cellspacing="0" style="margin-top:4px">

                <tr>
                  <td width="66">&nbsp;</td>
                  <td width="266" valign="top"><table width="260" height="105" style="margin-top:10px">
                      <tr>
                        <td height="99" valign="top"><div style="position:absolute; margin-left:150px; width: 118px;"><span style="margin-left:0px;float:right; margin-right:30px; margin-top:-6px">Option(s)</span></div>
                          <br/>
                          <div style="margin-left:40px; margin-top:0px;">
                            <table width="201" height="25" border="0" cellpadding="0" cellspacing="0" style="font-size:10px; font-family:Arial, Helvetica, sans-serif">

                              <tr>
                                <td width="30" align="center"><input type="checkbox" name="achat" value="1" id="buy_at_end" onclick="Chkbox(this.id);traitement_check();"></td>
                                <td width="92" align="left"><span style="font-size:14px">Achat &agrave; terme</span></td>
                                <td width="79" align="right"><div align="right" id="starter_txt" style="text-align:right"></div></td>
                              </tr>
                            </table>
                            
                            <!-- NEXT !-->

                            
                            <table width="201" height="25" border="0" cellpadding="0" cellspacing="0" style="font-size:10px; font-family:Arial, Helvetica, sans-serif">
                              <tr>
                                <td width="30" align="center"><input type="checkbox" name="assist" value="1" id="help_desk" onclick="Chkbox(this.id);"></td>
                                <td width="92" align="left"><span style="font-size:14px; text-align:left">Assistance</span></td>
                                <td width="79" align="right"><div align="right" id="buy_at_end_txt"></div></td>
                              </tr>
                            </table>
                          
                            <!-- ON THE NEXT --></div>

                           
                              <div align="right" id="prix_f" style="text-align:right; position:absolute; width:100px; height:30px"></div>
                            </td>
                 </tr></table></td>
                </tr>
              </table></td>
            <td width="342" valign="top"><!-- DROITE !-->
              
             <table height="252" border="0" cellpadding="0" cellspacing="0" style="margin-top:39px">
          <tr>
            <td width="266" valign="top"><table width="260" height="134">

                <tr>
                   <td height="14" align="right"><b style=" color:#545252; margin-right:9px">CONFIRMATION</b></td>
                </tr>
                <tr>
                  <td height="99" valign="top"><div style="position:absolute; margin-left:20px; width: 118px;"><span style="float:left; margin-right:20px; margin-top:-8px">Choisissez</span></div>
                          <br/>
                          <div style="margin-left:10px; margin-top:15px;">
                            <table width="201" height="20" border="0" cellpadding="0" cellspacing="0" style="font-size:10px; font-family:Arial, Helvetica, sans-serif">

                              <tr>
                                <td width="37" align="center">&nbsp;</td>
                                <td align="center"><input type="image" name="action" value="ajout" src="images/bt_confirmation_fr.png" width="135" height="20"></td>
                              </tr>
                            </table>
                            
                            <!-- NEXT !-->
                     <table width="201" height="25" border="0" cellpadding="0" cellspacing="0" style="font-size:10px; font-family:Arial, Helvetica, sans-serif; margin-top:0px">
                              <tr>
                                <td width="37" align="center"><span style="font-size:14px">ou</span></td>

                                <td align="center"></td>
                              </tr>
                            </table>
                            <!-- ON THE NEXT -->
                            <table width="201" height="20" border="0" cellpadding="0" cellspacing="0" style="font-size:10px; font-family:Arial, Helvetica, sans-serif; margin-top:0px">
    <tr>
      <td width="37" align="center">&nbsp;</td>
      <td align="center"><input type="image" name="action" value="ajout1" src="images/bt_autresachats_fr.png" width="135" height="20"></td>
    </tr>

  </table>
  
  </div></td></tr></table>
<!-- NEXT RIGHT -----!-->
                    <div style="margin-top:75px">
                      <div style="margin-left:30px; margin-top:-5px; text-align:justify"> Confirmez votre choix ou cliquez sur &quot;Autre(s) achat(s) si vous souhaitez ajouter d'autres services.
                        <div style="float:left; margin-left:-25px; margin-top:-35px"><img src="images/logo_info.png" width="18" height="17" style=" margin-right:2px" /></div>
                      </div>
                    </div></td>
                </tr>

              </table></td>
          </tr>
        </table>
      </form>


dimanche 21 novembre 2010 à 00:11:32 | Re : checkbox plus prix

PetoleTeam

Membre Club
Réponse acceptée !
Bonjour,
ce qui marche pas :
Code Javascript :
if (achat.checked == true; )
; en trop !!!
achat qu'est ce ???
Code Javascript :
if (document.getElementById("achat").checked == true)
????

;O)
lundi 22 novembre 2010 à 17:02:26 | Re : checkbox plus prix

gfpl

bonjour,

merci pour ta réponse qui est bonne mais du coup les case ne se décoche plus ;(

du moins quand je met plusieurs conditions avec &&
j'ai essayer ceci

Code Javascript :
<script type="text/javascript" language="JavaScript">
function traitement_check()
{
     
     if (document.getElementById("premium").checked = true)
     {
		 ref=document.getElementById("prix_f");
	ref.innerHTML=\'&#8364; <span style="color:#C5281f; font-size:14px">399</span><span style="color:#545252; font-size:14px">,</span><span style="color:#C5281f; font-size:14px">99</span>/mois\';
     
     }else if ((document.getElementById("pro").checked = true) && (document.getElementById("premium").checked = false))
     {
		 ref=document.getElementById("prix_f");
	ref.innerHTML=\'&#8364; <span style="color:#C5281f; font-size:14px">217</span><span style="color:#545252; font-size:14px">,</span><span style="color:#C5281f; font-size:14px">99</span>/mois\';
	 }
		 
	 
	 
	 else{
     ref=document.getElementById("prix_f");
	ref.innerHTML=\'ggggg\';
     }
	 }
     </script>
mardi 23 novembre 2010 à 19:09:46 | Re : checkbox plus prix

PetoleTeam

Membre Club
Réponse acceptée !
Bonjour,
ne pas confondre affectation et test d'égalité
var val = 10;
on affecte à la variable val la valeur 10.
if( val == 10 ){...}
on teste si val est égal à 10.

donc revoir le test de ta fonction en mettant des ==

;O)
dimanche 28 novembre 2010 à 16:29:40 | Re : checkbox plus prix

gfpl

merci pour ta réponse en effet c'est assez bête de ma part :)

dimanche 28 novembre 2010 à 17:37:53 | Re : checkbox plus prix

PetoleTeam

Membre Club
Bonjour,
un petit lien pour une meilleur approche de tous cela
Programmation JavaScript Opérateurs
le reste n'est pas inintéressant!

;O)
dimanche 28 novembre 2010 à 21:42:05 | Re : checkbox plus prix

gfpl

c'est les même que php pour les opérateurs c'est ma faute ;) merci du lien


Cette discussion est classée dans : document, false, ref, getelementbyid, checked


Répondre à ce message

Sujets en rapport avec ce message

acces au champ d un formulaire par variable [ par Poulipe ] Bonjour,je cherche mais sans resultat comment remplacer ca :if(document.contact.interet_1.checked!=false){ ++temoin;}if(document.contact.interet_2.che Problème de formulaire [ par beku ] Bonjour à tous !J'ai n problème avec ce formulaire : quand je clicke sur mon bouton de validation, j'ai l'impression que le navigateur ne lance pas la document.getElementById marche pas [ par hackademius ] salut a tous , j'ai un ptit probleme et j'ai pas trouvé de solutions ici Dans mons cript javascipt j'ai   : isIE = (document.all)?true:false;          Affichage du contenu d'une variable. [ par developvbdebut ] Bonjour tout le mondeJe souhaite afficher le contenu de la variable note.Les fonctions ci dessous dans dans un script appart du fichier html.//ci dess par un checkBox les textBox seront visibles/invisibles... [ par aspkiddy ] Bonjour, j'ai un JavaScript pour un CheckBox. Lorsque l'on coche ce checkBox, certains TextBox seront invisibles les autres seront visible voici mon Modif innerHTML d'un div entre 2 XMLHttpRequest synchrones sous IE [ par pacadebord ] Bonjour, Je suis en train de concevoir un outil qui, au clic sur un bouton, parcours les lignes d'un tableau, chaque ligne contenant 3 colonnes (pour Ajax => Upload file [ par Bobshit75 ] Bonjour à tous, Voila je suis entrain de concevoir un formulaire pour upload des fichiers sur un serveur via de l'ajax natif. Voici mon code : [cod Formulaire dynamique et html pour un submit [ par spaceboy89 ] Bonjour, Je vais essayer de m'expliquer clairement sur ce problème qui me bloque depuis un moment. J'ai crée un formulaire html avec des parties en Probleme javascript au niveau du passage de variable [ par samox007 ] Bonjour, J'ai besoin de votre aide ,merci. [u]Etape 1(Code JavaScript):[/u] //Ajoute une ligne dans mon tableau function createLigne(date_semaine,a JS PARENT node [ par ghighidu63 ] Bonjour, j'ai crée ce sujet car j'ai besoin d'aide pour mon script. J'ai crée un truc pour Minimiser et Fermer un truc (Cacher/Afficher) Quand il y'en


Nos sponsors


Sondage...

CalendriCode

Mai 2012
LMMJVSD
 123456
78910111213
14151617181920
21222324252627
28293031   

Consulter la suite du CalendriCode

Photothèque

A découvrir



 
Développement réalisé par Nicolas SOREL (Nix) avec l'aide de : Cyril DURAND et Emmanuel (EBArtSoft), Merci à Vincent pour ses précieux conseils.
CodeS-SourceS.com© Toute reproduction même partielle est interdite sauf accord écrit du Webmaster
CodeS-SourceS.com© est une marque déposée tous droits réservés

Google Coop CodeS-SourceS Google Coop CodeS-SourceS
Temps d'éxécution de la page : 0,608 sec (3)

Nous contacter | Annoncer sur CodeS-SourceS | Mentions légales