IdentifiantMot de passe
Loading...
Mot de passe oublié ?Je m'inscris ! (gratuit)
Navigation

Inscrivez-vous gratuitement
pour pouvoir participer, suivre les réponses en temps réel, voter pour les messages, poser vos propres questions et recevoir la newsletter

JavaScript Discussion :

modifier attribut checked bouton radio


Sujet :

JavaScript

  1. #1
    Membre actif
    Profil pro
    Inscrit en
    Avril 2005
    Messages
    818
    Détails du profil
    Informations personnelles :
    Âge : 40
    Localisation : France, Drôme (Rhône Alpes)

    Informations forums :
    Inscription : Avril 2005
    Messages : 818
    Points : 288
    Points
    288
    Par défaut modifier attribut checked bouton radio
    comment faire pour modifier l'attribut checked d'un bouton radio en javascript.

    Voici mes boutons:
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
     
    <td><input type="radio" name="radiosexe1" id="radiosexe1" value=""></td>
    <td><input type="radio" name="radiosexe2" id="radiosexe2" value="" CHECKED></td>
    <td><input type="radio" name="radiocouleur1" id="radiocouleur1" value=""></td>
    <td><input type="radio" name="radiocouleur2" id="radiocouleur2" value="" CHECKED></td>
    En fait, si je clique sur une image au dessus du bouton je veux associer une action javascript qui passe l'attribut checked au radio correspondant...
    (radiosexe1=femme radiosexe2=homme radiocouleur1=noir radiocouleur2=blanc)

  2. #2
    Membre habitué Avatar de avogadro
    Profil pro
    Inscrit en
    Mars 2006
    Messages
    412
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Mars 2006
    Messages : 412
    Points : 188
    Points
    188
    Par défaut
    ca peut t'aider :
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    <html>
     
    <head>
    <script language="JavaScript">
    function decoche() {
    document.forms[0].toto.checked = false;
    }
    </script>
    </head>
     
    <body>
    <input type="button" value="bloppppp" onClick="decoche()">
    <form>
    <input type="radio" id="toto" value="" CHECKED>
    </form>
    </body>
     
    </html>

  3. #3
    Rédacteur/Modérateur

    Avatar de SpaceFrog
    Homme Profil pro
    Développeur Web Php Mysql Html Javascript CSS Apache - Intégrateur - Bidouilleur SharePoint
    Inscrit en
    Mars 2002
    Messages
    39 640
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 74
    Localisation : Royaume-Uni

    Informations professionnelles :
    Activité : Développeur Web Php Mysql Html Javascript CSS Apache - Intégrateur - Bidouilleur SharePoint
    Secteur : Industrie

    Informations forums :
    Inscription : Mars 2002
    Messages : 39 640
    Points : 66 664
    Points
    66 664
    Billets dans le blog
    1
    Par défaut
    quel interet d'avoir des names différents pour tous ?
    ils devraient être associés deux par deux non ?

  4. #4
    Membre actif
    Profil pro
    Inscrit en
    Avril 2005
    Messages
    818
    Détails du profil
    Informations personnelles :
    Âge : 40
    Localisation : France, Drôme (Rhône Alpes)

    Informations forums :
    Inscription : Avril 2005
    Messages : 818
    Points : 288
    Points
    288
    Par défaut
    Ah ok alors en fait il faut leur mettre le meme nom et pas le meme id qd ils sont associés?

    Comme ca:
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
     
    <td><input type="radio" name="radiosexe" id="radiosexe1" value=""></td>
    <td><input type="radio" name="radiosexe" id="radiosexe2" value="" CHECKED></td>
    <td><input type="radio" name="radiocouleur" id="radiocouleur1" value=""></td>
    <td><input type="radio" name="radiocouleur" id="radiocouleur2" value="" CHECKED></td>
    Ou on leur met le meme id aussi comme ca? :
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
     
    <td><input type="radio" name="radiosexe" id="radiosexe" value=""></td>
    <td><input type="radio" name="radiosexe" id="radiosexe" value="" CHECKED></td>
    <td><input type="radio" name="radiocouleur" id="radiocouleur" value=""></td>
    <td><input type="radio" name="radiocouleur" id="radiocouleur" value="" CHECKED></td>

  5. #5
    Rédacteur/Modérateur

    Avatar de SpaceFrog
    Homme Profil pro
    Développeur Web Php Mysql Html Javascript CSS Apache - Intégrateur - Bidouilleur SharePoint
    Inscrit en
    Mars 2002
    Messages
    39 640
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 74
    Localisation : Royaume-Uni

    Informations professionnelles :
    Activité : Développeur Web Php Mysql Html Javascript CSS Apache - Intégrateur - Bidouilleur SharePoint
    Secteur : Industrie

    Informations forums :
    Inscription : Mars 2002
    Messages : 39 640
    Points : 66 664
    Points
    66 664
    Billets dans le blog
    1
    Par défaut
    non l'id doit être unique ...

  6. #6
    Membre actif
    Profil pro
    Inscrit en
    Avril 2005
    Messages
    818
    Détails du profil
    Informations personnelles :
    Âge : 40
    Localisation : France, Drôme (Rhône Alpes)

    Informations forums :
    Inscription : Avril 2005
    Messages : 818
    Points : 288
    Points
    288
    Par défaut
    J'ai fait ca mais ca marche pas...
    Ou est le problème?:
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
     
    <form name="ajoutpanier">
    <tr> 
    <td><a href="javascript:changesexe('femme');"><img src="images/structure/symbole_femme.gif" width="43" height="63" border="0" /></a></td>
    <td><a href="javascript:changesexe('homme');"><img src="images/structure/symbole_homme.gif" width="43" height="63" border="0" /></a></td>
    </tr>
    <tr> 
    <td><input type="radio" name="radiosexe" id="radiosexe1" value=""></td>
    <td><input type="radio" name="radiosexe" id="radiosexe2" value="" CHECKED></td>
    </tr>
    </form>
    et dans la partie javascript:
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
     
    function changesexe(sexe){
      if(sexe=="homme")
      {
    	document.ajoutpanier.radiosexe1.checked=false;
        document.ajoutpanier.radiosexe2.checked=true;
      }
      else if(sexe=="femme")
      {
        	document.ajoutpanier.radiosexe2.checked=false;
    	document.ajoutpanier.radiosexe1.checked=true;
      }
    }

  7. #7
    Membre habitué Avatar de avogadro
    Profil pro
    Inscrit en
    Mars 2006
    Messages
    412
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Mars 2006
    Messages : 412
    Points : 188
    Points
    188
    Par défaut
    pour avant, maniere lourde :
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    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
    <html>
     
    <head>
    <script language="JavaScript">
    function decoche() {
    document.forms[0].toto.checked = false;
    document.forms[0].blip.checked = false;
    document.forms[0].titi.checked = false;
    document.forms[0].blop.checked = false;
    }
    </script>
    </head>
     
    <body>
    <input type="button" value="bloppppp" onClick="decoche()">
    <form>
    <input type="radio" name="groupe1" id="toto" value="" CHECKED>
    <input type="radio" name="groupe1" id="titi" value="">
     
    <input type="radio" name="groupe2" id="blip" value="" CHECKED>
    <input type="radio" name="groupe2" id="blop" value="">
    </form>
    </body>
     
    </html>
    ps : ta nouvelle fonction marche !

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    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
    <html>
     
    <head>
    <script language="JavaScript">
    function changesexe(sexe){
      if(sexe=="homme")
      {
    	document.ajoutpanier.radiosexe1.checked=false;
        document.ajoutpanier.radiosexe2.checked=true;
      }
      else if(sexe=="femme")
      {
        	document.ajoutpanier.radiosexe2.checked=false;
    	document.ajoutpanier.radiosexe1.checked=true;
      }
    }
    </script>
    </head>
     
    <body>
    <form name="ajoutpanier">
    <a href="javascript:changesexe('femme');"><img src="http://images.google.fr/images?q=tbn:XNd6mqXi9Pd2SM:http://www.advalvas.be/fr/images/stories/cinema/scarlett0610022.jpg" width="43" height="63" border="0" /></a>
    <td><a href="javascript:changesexe('homme');"><img src="http://images.google.fr/images?q=tbn:aKMy27shPrfc7M:http://www.lesailes.com/fr/images/mode/produit_coupdoeil_h/homme_01.jpg" width="43" height="63" border="0" /></a>
    <br/>
    <input type="radio" name="radiosexe" id="radiosexe1" value="femme cochée">femme<br/>
    <input type="radio" name="radiosexe" id="radiosexe2" value="homme cochée" CHECKED>homme
     
    </form>
    </body>
     
    </html>

  8. #8
    Rédacteur/Modérateur

    Avatar de SpaceFrog
    Homme Profil pro
    Développeur Web Php Mysql Html Javascript CSS Apache - Intégrateur - Bidouilleur SharePoint
    Inscrit en
    Mars 2002
    Messages
    39 640
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 74
    Localisation : Royaume-Uni

    Informations professionnelles :
    Activité : Développeur Web Php Mysql Html Javascript CSS Apache - Intégrateur - Bidouilleur SharePoint
    Secteur : Industrie

    Informations forums :
    Inscription : Mars 2002
    Messages : 39 640
    Points : 66 664
    Points
    66 664
    Billets dans le blog
    1
    Par défaut
    ouf tu te complique la vie !!!
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
     
    <script type='text/javascript'>
    function changesexe(sexe){
    	document.getElementById('radiosexe1').checked=(sexe=="femme")
    	document.getElementById('radiosexe2').checked=(sexe=="homme")
    	}
     </script>
    </head>
     
    <body>
    <form name="ajoutpanier">
    <table>
    <tr> 
    <td><img src="images/structure/symbole_femme.gif" width="43" height="63" border="0" onclick="changesexe('femme')" style='cursor:poniter'  /></td>
    <td><img src="images/structure/symbole_homme.gif" width="43" height="63" border="0" onclick="changesexe('homme')" style='cursor:poniter' /></a></td>
    </tr>
    <tr> 
    <td><input type="radio" name="radiosexe" id="radiosexe1" value=""></td>
    <td><input type="radio" name="radiosexe" id="radiosexe2" value="" CHECKED></td>
    </tr>
    </form>

  9. #9
    Membre actif
    Profil pro
    Inscrit en
    Avril 2005
    Messages
    818
    Détails du profil
    Informations personnelles :
    Âge : 40
    Localisation : France, Drôme (Rhône Alpes)

    Informations forums :
    Inscription : Avril 2005
    Messages : 818
    Points : 288
    Points
    288
    Par défaut
    Ca marche pas...
    La console d'erreur me renvoi :
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
     
    Erreur : document.radiosexe has no properties
    Fichier source : http://127.0.0.1/KdoDebil/index.php?cat=01&souscat=01
    Ligne : 199

  10. #10
    Membre habitué Avatar de avogadro
    Profil pro
    Inscrit en
    Mars 2006
    Messages
    412
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Mars 2006
    Messages : 412
    Points : 188
    Points
    188
    Par défaut
    est cencé etre le nom de ta form, sans la forme il faut utilisé une autre méthode !

  11. #11
    Membre actif
    Profil pro
    Inscrit en
    Avril 2005
    Messages
    818
    Détails du profil
    Informations personnelles :
    Âge : 40
    Localisation : France, Drôme (Rhône Alpes)

    Informations forums :
    Inscription : Avril 2005
    Messages : 818
    Points : 288
    Points
    288
    Par défaut
    Qu'est ce que tu veux dire? Je ne vois pas ou tu veux en venir....

  12. #12
    Rédacteur/Modérateur

    Avatar de SpaceFrog
    Homme Profil pro
    Développeur Web Php Mysql Html Javascript CSS Apache - Intégrateur - Bidouilleur SharePoint
    Inscrit en
    Mars 2002
    Messages
    39 640
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 74
    Localisation : Royaume-Uni

    Informations professionnelles :
    Activité : Développeur Web Php Mysql Html Javascript CSS Apache - Intégrateur - Bidouilleur SharePoint
    Secteur : Industrie

    Informations forums :
    Inscription : Mars 2002
    Messages : 39 640
    Points : 66 664
    Points
    66 664
    Billets dans le blog
    1
    Par défaut
    heu si ça vous gène que je vous file du code qui marche dites le ...

  13. #13
    Membre actif
    Profil pro
    Inscrit en
    Avril 2005
    Messages
    818
    Détails du profil
    Informations personnelles :
    Âge : 40
    Localisation : France, Drôme (Rhône Alpes)

    Informations forums :
    Inscription : Avril 2005
    Messages : 818
    Points : 288
    Points
    288
    Par défaut
    heu si ça vous gène que je vous file du code qui marche dites le ...
    Désolé mais je viens de tester avec ton code et ca n marche pas...
    Je ne comprend pas ce que la console d'erreur javascript veut dire qd elle dit:
    document.radiosexe has no properties

  14. #14
    Membre habitué Avatar de avogadro
    Profil pro
    Inscrit en
    Mars 2006
    Messages
    412
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Mars 2006
    Messages : 412
    Points : 188
    Points
    188
    Par défaut
    Citation Envoyé par calitom
    Désolé mais je viens de tester avec ton code et ca n marche pas...
    Je ne comprend pas ce que la console d'erreur javascript veut dire qd elle dit:
    si si il marche son code, copie ca tel quel :

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    <html>
    <head>
    <script type='text/javascript'>
    function changesexe(sexe){
    	document.getElementById('radiosexe1').checked=(sexe=="femme")
    	document.getElementById('radiosexe2').checked=(sexe=="homme")
    	}
     </script>
    </head>
     
    <body>
    <form name="ajoutpanier">
    <table>
    <tr> 
    <td><img src="images/structure/symbole_femme.gif" width="43" height="63" border="0" onclick="changesexe('femme')" style='cursor:poniter'  /></td>
    <td><img src="images/structure/symbole_homme.gif" width="43" height="63" border="0" onclick="changesexe('homme')" style='cursor:poniter' /></a></td>
    </tr>
    <tr> 
    <td><input type="radio" name="radiosexe" id="radiosexe1" value=""></td>
    <td><input type="radio" name="radiosexe" id="radiosexe2" value="" CHECKED></td>
    </tr>
    </form>
    </body>
    </html>
    ps : lol spacefrog ^^

  15. #15
    Membre actif
    Profil pro
    Inscrit en
    Avril 2005
    Messages
    818
    Détails du profil
    Informations personnelles :
    Âge : 40
    Localisation : France, Drôme (Rhône Alpes)

    Informations forums :
    Inscription : Avril 2005
    Messages : 818
    Points : 288
    Points
    288
    Par défaut
    Ah ouai!! Je viens de tester juste son code ca marche, mais qd je l'incorpore à mon code ca marche pas!!

    C horrible.
    Désolé d'avoir cru que ton code marchait pas! lol

    Mais je n'ai pas d'erreur ds mon code et je ne vois ps pourquoi ca marche pas...

  16. #16
    Membre habitué Avatar de avogadro
    Profil pro
    Inscrit en
    Mars 2006
    Messages
    412
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Mars 2006
    Messages : 412
    Points : 188
    Points
    188
    Par défaut
    envoie le en entier pour voir !

  17. #17
    Membre actif
    Profil pro
    Inscrit en
    Avril 2005
    Messages
    818
    Détails du profil
    Informations personnelles :
    Âge : 40
    Localisation : France, Drôme (Rhône Alpes)

    Informations forums :
    Inscription : Avril 2005
    Messages : 818
    Points : 288
    Points
    288
    Par défaut
    C long mais je l'envoi...
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    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
    68
    69
    70
    71
    72
    73
    74
    75
    76
    77
    78
    79
    80
    81
    82
    83
    84
    85
    86
    87
    88
    89
    90
    91
    92
    93
    94
    95
    96
    97
    98
    99
    100
    101
    102
    103
    104
    105
    106
    107
    108
    109
    110
    111
    112
    113
    114
    115
    116
    117
    118
    119
    120
    121
    122
    123
    124
    125
    126
    127
    128
    129
    130
    131
    132
    133
    134
    135
    136
    137
    138
    139
    140
    141
    142
    143
    144
    145
    146
    147
    148
    149
    150
    151
    152
    153
    154
    155
    156
    157
    158
    159
    160
    161
    162
    163
    164
    165
    166
    167
    168
    169
    170
    171
    172
    173
    174
    175
    176
    177
    178
    179
    180
    181
    182
    183
    184
    185
    186
    187
    188
    189
    190
    191
    192
    193
    194
    195
    196
    197
    198
    199
    200
    201
    202
    203
    204
    205
    206
    207
    208
    209
    210
    211
    212
    213
    214
    215
    216
    217
    218
    219
    220
    221
    222
    223
    224
    225
    226
    227
    228
    229
    230
    231
    232
    233
    234
    235
    236
    237
    238
    239
    240
    241
    242
    243
    244
    245
    246
    247
    248
    249
    250
    251
    252
    253
    254
    255
    256
    257
    258
    259
    260
    261
    262
    263
    264
    265
    266
    267
    268
    269
    270
    271
    272
    273
    274
    275
    276
    277
    278
    279
    280
    281
    282
    283
    284
    285
    286
    287
    288
    289
    290
    291
    292
    293
    294
    295
    296
    297
    298
    299
    300
    301
    302
    303
    304
    305
    306
    307
    308
    309
    310
    311
    312
    313
    314
    315
    316
    317
    318
    319
    320
    321
    322
    323
    324
    325
    326
    327
    328
    329
    330
    331
    332
    333
    334
    335
    336
    337
    338
    339
    340
    341
    342
    343
    344
    345
    346
    347
    348
    349
    350
    351
    352
    353
    354
    355
    356
    357
    358
    359
    360
    361
    362
    363
    364
    365
    366
    367
    368
    369
    370
    371
    372
    373
    374
    375
    376
    377
    378
    379
    380
    381
    382
    383
    384
    385
    386
    387
    388
    389
    390
    391
    392
    393
    394
    395
    396
    397
    398
    399
    400
    401
    402
    403
    404
    405
    406
    407
    408
    409
    410
    411
    412
    413
    414
    415
    416
    417
    418
    419
    420
    421
    422
    423
    424
    425
    426
    427
    428
    429
    430
    431
    432
    433
    434
    435
    436
    437
    438
    439
    440
    441
    442
    443
    444
    445
    446
    447
    448
    449
    450
    451
    452
    453
    454
    455
    456
    457
    458
    459
    460
    461
    462
    463
    464
    465
    466
    467
    468
    469
    470
    471
    472
    473
    474
    475
    476
    477
    478
    479
    480
    481
    482
    483
    484
    485
    486
    487
    488
    489
    490
    491
    492
    493
    494
    495
    496
    497
    498
    499
    500
    501
    502
    503
    504
    505
    506
    507
    508
    509
    510
    511
    512
    513
    514
    515
    516
    517
    518
    519
    520
    521
    522
    523
    524
    525
    526
    527
    528
    529
    530
    531
    532
    533
    534
    535
    536
     
    <head>
    <title>t-shirt</title>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
     
     
    <!-- script pour le changement de couleur des Textes-->
    <script language=JavaScript>
    function coultshirt(couleur){
    document.getElementById('cell').style.backgroundColor=couleur;
    }
     
    function changecouleur(couleur){
      var a=document.getElementById('cell').style.backgroundImage;
      if((a=="url(images/structure/homme-blanc.gif)")||(a=="url(images/structure/homme-noir.gif)"))
      {
      	if(couleur=="blanc")
      	{
        	document.getElementById('cell').style.backgroundImage='url(images/structure/homme-blanc.gif)';
        	ancien=document.getElementById('imagetshirt').src;
    		nouveau=ancien.replace(/02.png/,"01.png");
    		document.getElementById('imagetshirt').src=nouveau;
    		document.getElementById('radiocouleur1').checked=true;
      	}
      	else if(couleur=="noir")
      	{
        	document.getElementById('cell').style.backgroundImage='url(images/structure/homme-noir.gif)';
        	ancien=document.getElementById('imagetshirt').src;
    		nouveau=ancien.replace(/01.png/,"02.png");
    		document.getElementById('imagetshirt').src=nouveau;
    		document.getElementById('radiocouleur2').checked=true;
      	}
      }
      else if((a=="url(images/structure/femme-blanc.gif)")||(a=="url(images/structure/femme-noir.gif)"))
      {
    	if(couleur=="blanc")
      	{
        	document.getElementById('cell').style.backgroundImage='url(images/structure/femme-blanc.gif)';
        	ancien=document.getElementById('imagetshirt').src;
        	nouveau=ancien.replace(/02.png/,"01.png");
    		document.getElementById('imagetshirt').src=nouveau;
    		document.getElementById('radiocouleur1').checked=true;
      	}
      	else if(couleur=="noir")
      	{
        	document.getElementById('cell').style.backgroundImage='url(images/structure/femme-noir.gif)';
        	ancien=document.getElementById('imagetshirt').src;
    		nouveau=ancien.replace(/01.png/,"02.png");
    		document.getElementById('imagetshirt').src=nouveau;
    		document.getElementById('radiocouleur2').checked=true;
      	}
      }
    }
     
    function rech_tableau(chaine,tab){
      var index_du_tableau=-1;
      for(elt in tab)
      {
        index_du_tableau++;
        if(tab[elt]==chaine)
    	{
    	  return index_du_tableau;
    	}
      }
      index_du_tableau=-1;
      return index_du_tableau;
    }
     
    function changesexe(sexe,prix_produits_js,refs_produits_js){
      document.getElementById('radiosexe1').checked=(sexe=="femme")
      document.getElementById('radiosexe2').checked=(sexe=="homme")
      var ref=document.getElementById('ref_produit').innerHTML;
      var id_tableau=rech_tableau(ref,refs_produits_js);
      if(sexe=="homme")
      {
        document.getElementById('cell').style.backgroundImage='url(images/structure/homme-blanc.gif)';
        ancien=document.getElementById('imagetshirt').src;
        nouveau=ancien.replace(/02.png/,"01.png");
    	document.getElementById('imagetshirt').src=nouveau;
    	document.getElementById('prix_produit').innerHTML=prix_produits_js[0][id_tableau];
     
      }
      else if(sexe=="femme")
      {
        document.getElementById('cell').style.backgroundImage='url(images/structure/femme-blanc.gif)';
        ancien=document.getElementById('imagetshirt').src;
        nouveau=ancien.replace(/02.png/,"01.png");
    	document.getElementById('imagetshirt').src=nouveau;
    	document.getElementById('prix_produit').innerHTML=prix_produits_js[2][id_tableau];
      }
    }
     
    function changement(refs_produits_js,noms_js,descs_produits_js,prix_produits_js,indice_rand)
    {
    	if((indice_rand=="0")||(indice_rand=="1")||(indice_rand=="2"))
    	{
    		id_tableau=indice_rand;	
    	}
    	else
    	{
    		id_tableau=document.getElementById('choixTextes').options[document.getElementById('choixTextes').selectedIndex].value;
    	}
    	var test_coul_image=document.getElementById('imagetshirt').src;
    	if(test_coul_image.search("01.png")!=-1)
    	{
    		coul="01.png";
    	}
    	else
    	{
    		coul="02.png";
    	}
    	document.getElementById('imagetshirt').src='images/produits/'+refs_produits_js[id_tableau]+coul;
     
    	document.getElementById('nom_produit').innerHTML='Texte : '+noms_js[id_tableau];
    	document.getElementById('desc_produit').innerHTML=descs_produits_js[id_tableau];
    	document.getElementById('ref_produit').innerHTML=refs_produits_js[id_tableau];
    	var testprix=document.getElementById('cell').style.backgroundImage;
    	if(testprix.search("homme")!=-1)
    	{
    		document.getElementById('prix_produit').innerHTML=prix_produits_js[0][id_tableau];
    	}
    	else
    	{
    		document.getElementById('prix_produit').innerHTML=prix_produits_js[2][id_tableau];
    	}
    }
    </script>
     
    <!-- feuille de style des polices-->
    <style>
    .verdaNoir01 {
    color: #000000;
    	font-family: Verdana, Arial, Helvetica, sans-serif;
    	font-size: 11px;
    }
    .verdaNoir02 {
    color: #000000;
    	font-family: Verdana, Arial, Helvetica, sans-serif;
    	font-size: 14px;
    }
    .arialNoirCouleurs {
    color: #000000;
    	font-family: Arial, Helvetica, sans-serif;
    	font-size: 10px;
    }
    .verdaRose02 {
    color: #ED145B;
    	font-family: Verdana, Arial, Helvetica, sans-serif;
    	font-size: 14px;
    }
    .verdaRosePrix {
    color: #ED145B;
    	font-family: Arial, Helvetica, sans-serif;
    	font-size: 30px;
    	font-weight: bold;
    }
    .style_ref {
    font-size: 11px;
    font-family: Verdana, Arial, Helvetica, sans-serif;
    color: #ED145B;	
    }
    </style>
    </head>
     
    <?
    //Pour transmettre le tableau a la fonction changement il faut le transformer en tableau JS
    function construisTableauJS($tableauPHP, $nomTableauJS){
       echo $nomTableauJS." = new Array();";
       for($i = 0; $i < count($tableauPHP); $i++){
          if(!is_array($tableauPHP[$i])){
             echo $nomTableauJS."[".$i."] = '".$tableauPHP[$i]."';";
          }
          else{
             construisTableauJS($tableauPHP[$i], $nomTableauJS."[".$i."]");
          }
       }
       return;
    }
     
    include("connection_bdd.php");
    // Connexion à la BDD
    $connect = @mysql_connect($host,$user,$password);
    $select_base=@mysql_selectdb($base);
     
    // Tests de connexion
    if (!$select_base)
    {
        echo "<font color=\"#CC0000\"><b>Mauvaise configuration!!! </b></font><br>
    	Vérifiez que votre login et mot de passe sont bien saisi pour la connexion
    	à la base <b>$base</b>";
    	exit();
    }			
     
    if($souscat=="")
    {
    	$requete = "SELECT * FROM produit WHERE statut_produit!=0 AND num_categorie='01'";
    }
    else
    {
    	$requete = "SELECT * FROM produit WHERE statut_produit!=0 AND num_categorie='01' AND num_sous_categorie='$souscat'";
    }
    $result = mysql_query($requete);
     
    $nb_resultat=mysql_num_rows($result);
    if($nb_resultat==0)
    {
      echo "Aucun résultat trouvé!";
      exit();
    }
    else
    {
    	$i=0;
    	while ($row = mysql_fetch_array($result))
    	{						
    		$id_produit = $row["id_produit"];
    		$ref_produit = $row["reference_produit"];
    		$ref_fournisseur = $row["ref_chez_fournisseur"];
    		$marque = $row["marque"];
    		$logo_marque = $row["logo_marque"];
    		$nom_produit = $row["nom_produit"];
    		$prix_achat_homme_court = $row["prix_achat_homme_court"];
    		$prix_achat_homme_long = $row["prix_achat_homme_long"];
    		$prix_achat_femme_court = $row["prix_achat_femme_court"];
    		$prix_achat_femme_long = $row["prix_achat_femme_long"];
    		$prix_vente_homme_court = $row["prix_vente_homme_court"];
    		$prix_vente_homme_long = $row["prix_vente_homme_long"];
    		$prix_vente_femme_court = $row["prix_vente_femme_court"];
    		$prix_vente_femme_long = $row["prix_vente_femme_long"];
    		$prix_promo = $row["prix_promo"];
    		$poids = $row["poids"];
    		$img_mini = $row["img_mini"];
    		$img_prod = $row["img_prod"];
    		$statut_produit = $row["statut_produit"];
    		$num_categorie = $row["num_categorie"];
    		$num_sous_categorie = $row["num_sous_categorie"];
    		$desc_simple = $row["desc_simple"];
    		$desc_long = $row["desc_long"];
    		$type_produit = $row["type_produit"];
     
    		if($prix_promo!=0)
    		{
    			$prix_vente_homme_court=$prix_promo;
    			$prix_vente_homme_long=$prix_promo;
    			$prix_vente_femme_court=$prix_promo;
    			$prix_vente_femme_long=$prix_promo;
    		}
    		$ids_produits[$i]=$id_produit;
    		$refs_produits[$i]=$ref_produit;
    		$noms[$i]=$nom_produit;
    		$prix_produits[0][$i]=$prix_vente_homme_court;
    		$prix_produits[1][$i]=$prix_vente_homme_long;
    		$prix_produits[2][$i]=$prix_vente_femme_court;
    		$prix_produits[3][$i]=$prix_vente_femme_long;
    		$imgs_produits[$i]=$img_mini;
    		$descs_simples[$i]=$desc_simple;
     
    		$i++;
    	}
    }
     
    mysql_close($connect);
     
    //On transforme les tableaux en tableaux Javascript pour pouvoir les faire interpréter dans la fonction changement
    echo "<script type='text/javascript'>";
    construisTableauJS($refs_produits, "refs_produits_js");
    construisTableauJS($noms, "noms_js");
    construisTableauJS($descs_simples, "descs_produits_js");
    construisTableauJS($prix_produits, "prix_produits_js");
    echo "</script> ";
    ?>
     
    <body bgcolor="#FFFFFF" leftmargin="0" topmargin="0" marginwidth="0" marginheight="0">
    <div align="center"> </div>
     
    <form name="ajoutpanier">
    <table width="630" border="0" align="center" cellpadding="0" cellspacing="0">
      <tr> 
        <td width="399" align="center"><img src="images/structure/cadre-coul-article.gif" width="630" height="34" /></td>
      </tr>
      <tr> 
        <td align="center" background="images/structure/cadre-new-middle.gif"> 
          <TABLE cellSpacing=0 width=610 align=center>
           <TBODY>
              <TR> 
    			<td style="background-color:#6699FF;background-image:url(images/structure/homme-blanc.gif);width:298px;height:450px" valign="top" id="cell">
    			  <table width="300" height="410" border="0" cellpadding="0" cellspacing="0">
                    <tr> 
                      <td height="170">&nbsp;</td>
                    </tr>
                    <tr> 
                      <td id="produit" height="106" align="center"><img src="images/produits/<?echo $refs_produits[0];?>01.png" id="imagetshirt" width="136" height="104" /></td>
                    </tr>
                    <tr> 
                      <td>&nbsp;</td>
                    </tr>
                  </table>
    			</TD>
                <TD width=306 align="center" valign="top"> <table width="300" height="360" border="0" align="center" cellpadding="0" cellspacing="0">
                    <tr align="center"> 
                      <td align="right" valign="top"> <p class="verdaRose02">Dites 
                          leurs vos 4 v&eacute;rit&eacute;s!</p></td>
                    </tr>
                    <tr align="center"> 
                      <td height="19" align="right" valign="top"><hr size="1" noshade></td>
                    </tr>
                    <tr align="center"> 
                      <td align="right" valign="top"> <table width="300" border="0" cellspacing="0" cellpadding="0">
                          <tr valign="bottom"> 
                            <td colspan="4"> <table width="300" border="0" cellspacing="0" cellpadding="0">
                                <tr> 
                                  <td colspan="4"><p class="verdaNoir01" id="nom_produit">Texte 
                                      : <?echo $noms[0];?></p></td>
                                </tr>
                                <tr> 
                                  <td colspan="4"><hr size="1" noshade></td>
                                </tr>
                                <tr> 
                                  <td width="186"><p class="verdaNoir01" id="desc_produit"><?echo $descs_simples[0];?></p></td>
                                  <td width="16"><img src="images/structure/fleche.gif" width="15" height="8" /></td>
                                  <td width="29" align="center"><p class="verdaNoir01">Ref.</p></td>
                                  <td width="69" align="center"><p class="style_ref" id="ref_produit"><?echo $refs_produits[0];?></p></td>
                                </tr>
                              </table></td>
                          </tr>
                          <tr> 
                            <td colspan="4"><hr size="1" noshade></td>
                          </tr>
                          <tr align="left"> 
                            <td colspan="4"> <table width="285" border="0" cellspacing="0" cellpadding="0">
                                <tr> 
                                  <td width="58" align="center"><a href="javascript:changesexe('femme',prix_produits_js,refs_produits_js);"><img src="images/structure/symbole_femme.gif" width="43" height="63" border="0" /></a></td>
                                  <td width="55" align="center"><a href="javascript:changesexe('homme',prix_produits_js,refs_produits_js);"><img src="images/structure/symbole_homme.gif" width="43" height="63" border="0" /></a></td>
                                  <td width="50" rowspan="2" align="center"><p class="verdaNoir01">t-shirt<br />
                                      noir<br />
                                      ou<br />
                                      blanc</p></td>
                                  <td width="62" align="center"><a href="javascript:changecouleur('noir');"><img src="images/choix_tshirt/t-shirt-noir-V.gif" width="50" height="47" border="0" /></a></td>
                                  <td width="60" align="center"><a href="javascript:changecouleur('blanc');"><img src="images/choix_tshirt/t-shirt-blanc-V.gif" width="50" height="47" border="0" /></a></td>
                                </tr>
                                <tr align="center"> 
                                  <td width="58"><input type="radio" name="radiosexe" id="radiosexe1" value="femme"></td>
                                  <td><input type="radio" name="radiosexe" id="radiosexe2" value="homme" CHECKED></td>
                                  <td width="62" align="center"> <input type="radio" name="radiocouleur" id="radiocouleur1" value="noir"></td>
                                  <td width="60" align="center"> <input type="radio" name="radiocouleur" id="radiocouleur2" value="blanc" CHECKED></td>
                                </tr>
                              </table></td>
                          </tr>
                          <tr> 
                            <td colspan="4"><hr size="1" noshade></td>
                          </tr>
                          <tr align="center"> 
                            <td colspan="3"> <select name="select2" style="background-color:#dadada">
                                <option selected>--Tailles--</option>
                                <option>S ou 36</option>
                                <option>M ou 40</option>
                                <option>L ou 42</option>
                                <option>XL ou 44</option>
                              </select> </td>
                            <td width="158"><select name="select_sous_cat" id="select_sous_cat" style="background-color:#dadada" onChange="location.href='index.php?cat=01&souscat='+document.getElementById('select_sous_cat').options[document.getElementById('select_sous_cat').selectedIndex].value ">
                                <option selected>--Th&ecirc;mes--</option>
                                <option value="01">je deteste...</option>
                                <option value="02">la famille...</option>
                                <option value="03">moi je...</option>
                                <option value="04">les $...</option>
                                <option value="05">divers...</option>
                              </select></td>
                          </tr>
                          <tr> 
                            <td colspan="4"><hr size="1" noshade></td>
                          </tr>
                          <tr valign="bottom"> 
                            <td width="74" align="center" valign="middle"> <p class="verdaRosePrix" id="prix_produit"><?echo $prix_produits[0][0];?></p></td>
                            <td width="75" align="left" valign="middle"> <p class="verdaNoir01">Euros 
                                ttc</p></td>
                            <td width="151" colspan="2" align="right"><font color="#990000" size="6" face="Verdana, Arial, Helvetica, sans-serif"><font color="#6A0003" size="3"><strong><img src="images/structure/commander.gif" width="150" height="24" /></strong></font></font></td>
                          </tr>
                          <tr> 
                            <td colspan="4" align="left" valign="middle"><hr size="1" noshade></td>
                          </tr>
                          <tr align="center"> 
                            <td colspan="4" valign="middle"> <font color="#ED145B" size="3" face="Verdana, Arial, Helvetica, sans-serif"> 
                              <strong>Vous avez le choix parmis :</strong> </font> 
                            </td>
                          </tr>
                          <tr align="center" valign="bottom"> 
                            <td colspan="4"><img src="images/structure/black_comment.gif" width="19" height="17" /> 
                              <select name="choixTextes" id="choixTextes" style="background-color:#dadada" onChange="javascript:changement(refs_produits_js,noms_js,descs_produits_js,prix_produits_js);">
                                <option selected>tous les textes suivants...</option>
                                <?
    							for($j=0;$j<$nb_resultat;$j++)
    							{
    								echo "<option value='$j'>$noms[$j]</option>";
    							}
    							?>
                              </select> </td>
                          </tr>
                          <?
    					  // Connexion à la BDD
    					  $connect = @mysql_connect($host,$user,$password);
                          $select_base=@mysql_selectdb($base);
     
    					  // Tests de connexion
    					  if (!$select_base)
      					  {
    					    echo "<font color=\"#CC0000\"><b>Mauvaise configuration!!! </b></font><br>
    						Vérifiez que votre login et mot de passe sont bien saisi pour la connexion
    						à la base <b>$base</b>";
    						exit();
    					  }			
     
    					  if($souscat=="")
    					  {
    					  	$requete = "SELECT * FROM produit WHERE statut_produit!=0 AND num_categorie='01' ORDER BY RAND() LIMIT 3";
    					  }
    					  else
    					  {
    						$requete = "SELECT * FROM produit WHERE statut_produit!=0 AND num_categorie='01' AND num_sous_categorie='$souscat' ORDER BY RAND() LIMIT 3";
    					  }
    					  $result = mysql_query($requete);
    					  $nb_resultat=mysql_num_rows($result);
    					  if($nb_resultat==0)
    					  {
    					    echo "Aucun résultat trouvé!";
    						exit();
    					  }
    					  else
    					  {
    					  	$i=0;
    						while ($row = mysql_fetch_array($result))
    						{
    							$id_produit_rand = $row["id_produit"];
    							$ref_produit_rand = $row["reference_produit"];
    							$nom_produit_rand = $row["nom_produit"];
    							$prix_vente_homme_court_rand = $row["prix_vente_homme_court"];
    							$prix_vente_homme_long_rand = $row["prix_vente_homme_long"];
    							$prix_vente_femme_court_rand = $row["prix_vente_femme_court"];
    							$prix_vente_femme_long_rand = $row["prix_vente_femme_long"];
    							$prix_promo_rand = $row["prix_promo"];
    							$desc_simple_rand = $row["desc_simple"];
    							if($prix_promo_rand!=0)
    							{
    								$prix_vente_homme_court_rand=$prix_promo_rand;
    								$prix_vente_homme_long_rand=$prix_promo_rand;
    								$prix_vente_femme_court_rand=$prix_promo_rand;
    								$prix_vente_femme_long_rand=$prix_promo_rand;
    							}
     
    							$ids_produits_rand[$i]=$id_produit_rand;
    							$refs_produits_rand[$i]=$ref_produit_rand;
    							$noms_rand[$i]=$nom_produit_rand;
    							$prix_produits_rand[0][$i]=$prix_vente_homme_court_rand;
    							$prix_produits_rand[1][$i]=$prix_vente_homme_long_rand;
    							$prix_produits_rand[2][$i]=$prix_vente_femme_court_rand;
    							$prix_produits_rand[3][$i]=$prix_vente_femme_long_rand;
    							$descs_simples_rand[$i]=$desc_simple_rand;
     
    							$i++;
    						}
    					  }
    					  mysql_close($connect);
     
    					  //On transforme les tableaux en tableaux Javascript pour pouvoir les faire interpréter dans la fonction changement
    					  echo "<script type='text/javascript'>";
    					  construisTableauJS($refs_produits_rand, "refs_produits_rand_js");
    					  construisTableauJS($noms_rand, "noms_rand_js");
    					  construisTableauJS($descs_simples_rand, "descs_produits_rand_js");
    					  construisTableauJS($prix_produits_rand, "prix_produits_rand_js");
    					  echo "</script> ";
    					  ?>
                          <tr align="left"> 
                            <td colspan="4" valign="middle"><p class="verdaRose02"><a onClick="javascript:changement(refs_produits_rand_js,noms_rand_js,descs_produits_rand_js,prix_produits_rand_js,0);">Ex : <?echo $noms_rand[0];?></a></p></td>
                          </tr>
                          <tr align="left"> 
                            <td colspan="4" valign="middle"><p class="verdaRose02"><a onClick="javascript:changement(refs_produits_rand_js,noms_rand_js,descs_produits_rand_js,prix_produits_rand_js,1);">Ex : <?echo $noms_rand[1];?></a></p></td>
                          </tr>
                          <tr align="left"> 
                            <td colspan="4" valign="middle"><p class="verdaRose02"><a onClick="javascript:changement(refs_produits_rand_js,noms_rand_js,descs_produits_rand_js,prix_produits_rand_js,2);">Ex : <?echo $noms_rand[2];?></a></p></td>
                          </tr>
                          <tr align="right"> 
                            <td colspan="4" valign="middle"><p class="verdaNoir01"><br />
                                Largeur du texte : env. 20 cm / Frais de port : 5&euro;</p></td>
                          </tr>
                        </table></td>
                    </tr>
                  </table>
    			</TD>
              </TR>
              <TR> 
                <TD colspan="2" align="center">
    			  <hr size="1" noshade>
    			    <table width="593" height="22" border="0" align="center" cellpadding="0" cellspacing="0">
                      <tr align="center" valign="top">
                        <td width="120" rowspan="2" bgcolor="#FFFFFF"><p class="verdaNoir01">couleur texte</p></td>
                        <td width="40" bgcolor="#6699FF"><a href="javascript:coultshirt('#6699FF')"><img height=10 src="images/choix_tshirt/bt_couleur.gif" width=40 border=0 /></a></td>
                        <td width="40" bgcolor="#0033CC"><a href="javascript:coultshirt('#0033CC')"><img height=10 src="images/choix_tshirt/bt_couleur.gif" width=40 border=0 /></a></td>
                        <td width="40" bgcolor="#000066"><a href="javascript:coultshirt('#000066')"><img height=10 src="images/choix_tshirt/bt_couleur.gif" width=40 border=0 /></a></td>
                        <td width="40" bgcolor="#CC66CC"><a href="javascript:coultshirt('#CC66CC')"><img height=10 src="images/choix_tshirt/bt_couleur.gif" width=40 border=0 /></a></td>
                        <td width="40" bgcolor="#FF3300"><a href="javascript:coultshirt('#FF3300')"><img height=10 src="images/choix_tshirt/bt_couleur.gif" width=40 border=0 /></a></td>
                        <td width="40" bgcolor="#CC0000"><a href="javascript:coultshirt('#CC0000')"><img height=10 src="images/choix_tshirt/bt_couleur.gif" width=40 border=0 /></a></td>
                        <td width="40" bgcolor="#FFFF00"><a href="javascript:coultshirt('#ffff00')"><img height=10 src="images/choix_tshirt/bt_couleur.gif" width=40 border=0 /></a></td>
                        <td width="40" bgcolor="#999933"><a href="javascript:coultshirt('#999933')"><img height=10 src="images/choix_tshirt/bt_couleur.gif" width=40 border=0 /></a></td>
                        <td width="40" bgcolor="#999999"><a href="javascript:coultshirt('#999999')"><img height=10 src="images/choix_tshirt/bt_couleur.gif" width=40 border=0 /></a></td>
                        <td width="40" bgcolor="#00FF00"><a href="javascript:coultshirt('#00FF00')"><img height=10 src="images/choix_tshirt/bt_couleur.gif" width=40 border=0 /></a></td>
                        <td width="40" bgcolor="#000000"><a href="javascript:coultshirt('#000000')"><img height=10 src="images/choix_tshirt/bt_couleur.gif" width=40 border=0 /></a></td>
                        <td width="40" bgcolor="#ffffff"><a href="javascript:coultshirt('#ffffff')"><img height=10 src="images/choix_tshirt/bt_couleur.gif" width=40 border=0 /></a></td>
                    </tr>
                    <tr align="center">
    				  <td width="40"><p class="arialNoirCouleurs">ciel</p></td>
                      <td width="40"><p class="arialNoirCouleurs">bleu</p></td>
                      <td width="40"><p class="arialNoirCouleurs">marine</p></td>
                      <td width="40"><p class="arialNoirCouleurs">Rose</p></td>
                      <td width="40"><p class="arialNoirCouleurs">orange</p></td>
                      <td width="40"><p class="arialNoirCouleurs">rouge</p></td>
                      <td width="40"><p class="arialNoirCouleurs">jaune</p></td>
                      <td width="40"><p class="arialNoirCouleurs">or</p></td>
                      <td width="40"><p class="arialNoirCouleurs">argent</p></td>
                      <td width="40"><p class="arialNoirCouleurs">vert fluo</p></td>
                      <td width="40"><p class="arialNoirCouleurs">noir</p></td>
                      <td width="40"><p class="arialNoirCouleurs">blanc</p></td>
                    </tr>
                  </table>
    			</TD>
              </TR>
            </TBODY>
          </TABLE>
    	</td>
      </tr>
      <tr> 
        <td align="center"><img src="images/structure/cadre-new-footer.gif" width="630" height="36" /></td>
      </tr>
    </table>
    </form>
    <p class="verdaRose02"><br /></p>
    <p class="verdaRose02">&nbsp;</p>
    <p>&nbsp;</p>
    </body>

  18. #18
    Membre actif
    Profil pro
    Inscrit en
    Avril 2005
    Messages
    818
    Détails du profil
    Informations personnelles :
    Âge : 40
    Localisation : France, Drôme (Rhône Alpes)

    Informations forums :
    Inscription : Avril 2005
    Messages : 818
    Points : 288
    Points
    288
    Par défaut
    Je vais mettre une version allégée du code avec juste les fonctions qui sont utilisées dans ce cas:
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    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
    68
    69
    70
    71
    72
    73
    74
    75
    76
    77
    78
    79
    80
    81
    82
    83
    84
    85
    86
    87
    88
    89
    90
    91
    92
    93
    94
    95
    96
    97
    98
    99
    100
    101
    102
    103
    104
    105
    106
    107
    108
    109
    110
    111
    112
    113
    114
    115
    116
    117
    118
    119
    120
    121
    122
    123
    124
    125
    126
    127
    128
    129
    130
    131
    132
    133
    134
    135
    136
    137
    138
    139
    140
    141
    142
    143
    144
    145
    146
    147
    148
    149
    150
    151
    152
    153
    154
    155
    156
    157
    158
    159
    160
    161
    162
    163
    164
    165
    166
    167
    168
    169
    170
    171
    172
    173
    174
    175
    176
    177
    178
    179
    180
    181
    182
    183
    184
    185
    186
    187
    188
    189
    190
    191
    192
    193
    194
    195
    196
    197
    198
    199
     
    <script language=JavaScript>
    function coultshirt(couleur){
    document.getElementById('cell').style.backgroundColor=couleur;
    }
     
    function changecouleur(couleur){
      var a=document.getElementById('cell').style.backgroundImage;
      if((a=="url(images/structure/homme-blanc.gif)")||(a=="url(images/structure/homme-noir.gif)"))
      {
      	if(couleur=="blanc")
      	{
        	document.getElementById('cell').style.backgroundImage='url(images/structure/homme-blanc.gif)';
        	ancien=document.getElementById('imagetshirt').src;
    		nouveau=ancien.replace(/02.png/,"01.png");
    		document.getElementById('imagetshirt').src=nouveau;
    		document.getElementById('radiocouleur1').checked=true;
      	}
      	else if(couleur=="noir")
      	{
        	document.getElementById('cell').style.backgroundImage='url(images/structure/homme-noir.gif)';
        	ancien=document.getElementById('imagetshirt').src;
    		nouveau=ancien.replace(/01.png/,"02.png");
    		document.getElementById('imagetshirt').src=nouveau;
    		document.getElementById('radiocouleur2').checked=true;
      	}
      }
      else if((a=="url(images/structure/femme-blanc.gif)")||(a=="url(images/structure/femme-noir.gif)"))
      {
    	if(couleur=="blanc")
      	{
        	document.getElementById('cell').style.backgroundImage='url(images/structure/femme-blanc.gif)';
        	ancien=document.getElementById('imagetshirt').src;
        	nouveau=ancien.replace(/02.png/,"01.png");
    		document.getElementById('imagetshirt').src=nouveau;
    		document.getElementById('radiocouleur1').checked=true;
      	}
      	else if(couleur=="noir")
      	{
        	document.getElementById('cell').style.backgroundImage='url(images/structure/femme-noir.gif)';
        	ancien=document.getElementById('imagetshirt').src;
    		nouveau=ancien.replace(/01.png/,"02.png");
    		document.getElementById('imagetshirt').src=nouveau;
    		document.getElementById('radiocouleur2').checked=true;
      	}
      }
    }
     
    function rech_tableau(chaine,tab){
      var index_du_tableau=-1;
      for(elt in tab)
      {
        index_du_tableau++;
        if(tab[elt]==chaine)
    	{
    	  return index_du_tableau;
    	}
      }
      index_du_tableau=-1;
      return index_du_tableau;
    }
     
    function changesexe(sexe,prix_produits_js,refs_produits_js){
      document.getElementById('radiosexe1').checked=(sexe=="femme")
      document.getElementById('radiosexe2').checked=(sexe=="homme")
      var ref=document.getElementById('ref_produit').innerHTML;
      var id_tableau=rech_tableau(ref,refs_produits_js);
      if(sexe=="homme")
      {
        document.getElementById('cell').style.backgroundImage='url(images/structure/homme-blanc.gif)';
        ancien=document.getElementById('imagetshirt').src;
        nouveau=ancien.replace(/02.png/,"01.png");
    	document.getElementById('imagetshirt').src=nouveau;
    	document.getElementById('prix_produit').innerHTML=prix_produits_js[0][id_tableau];
     
      }
      else if(sexe=="femme")
      {
        document.getElementById('cell').style.backgroundImage='url(images/structure/femme-blanc.gif)';
        ancien=document.getElementById('imagetshirt').src;
        nouveau=ancien.replace(/02.png/,"01.png");
    	document.getElementById('imagetshirt').src=nouveau;
    	document.getElementById('prix_produit').innerHTML=prix_produits_js[2][id_tableau];
      }
    }
     
     
    </script>
     
    <?
    //Pour transmettre le tableau a la fonction changement il faut le transformer en tableau JS
    function construisTableauJS($tableauPHP, $nomTableauJS){
       echo $nomTableauJS." = new Array();";
       for($i = 0; $i < count($tableauPHP); $i++){
          if(!is_array($tableauPHP[$i])){
             echo $nomTableauJS."[".$i."] = '".$tableauPHP[$i]."';";
          }
          else{
             construisTableauJS($tableauPHP[$i], $nomTableauJS."[".$i."]");
          }
       }
       return;
    }
     
    include("connection_bdd.php");
    // Connexion à la BDD
    $connect = @mysql_connect($host,$user,$password);
    $select_base=@mysql_selectdb($base);
     
    // Tests de connexion
    if (!$select_base)
    {
        echo "<font color=\"#CC0000\"><b>Mauvaise configuration!!! </b></font><br>
    	Vérifiez que votre login et mot de passe sont bien saisi pour la connexion
    	à la base <b>$base</b>";
    	exit();
    }			
     
    if($souscat=="")
    {
    	$requete = "SELECT * FROM produit WHERE statut_produit!=0 AND num_categorie='01'";
    }
    else
    {
    	$requete = "SELECT * FROM produit WHERE statut_produit!=0 AND num_categorie='01' AND num_sous_categorie='$souscat'";
    }
    $result = mysql_query($requete);
     
    $nb_resultat=mysql_num_rows($result);
    if($nb_resultat==0)
    {
      echo "Aucun résultat trouvé!";
      exit();
    }
    else
    {
    	$i=0;
    	while ($row = mysql_fetch_array($result))
    	{						
    		$id_produit = $row["id_produit"];
    		$ref_produit = $row["reference_produit"];
    		$statut_produit = $row["statut_produit"];
    		$num_categorie = $row["num_categorie"];
    		$num_sous_categorie = $row["num_sous_categorie"];
    		$desc_simple = $row["desc_simple"];
    		$desc_long = $row["desc_long"];
    		$type_produit = $row["type_produit"];
     
    		if($prix_promo!=0)
    		{
    			$prix_vente_homme_court=$prix_promo;
    			$prix_vente_homme_long=$prix_promo;
    			$prix_vente_femme_court=$prix_promo;
    			$prix_vente_femme_long=$prix_promo;
    		}
    		$ids_produits[$i]=$id_produit;
    		$refs_produits[$i]=$ref_produit;
    		$noms[$i]=$nom_produit;
    		$prix_produits[0][$i]=$prix_vente_homme_court;
    		$prix_produits[1][$i]=$prix_vente_homme_long;
    		$prix_produits[2][$i]=$prix_vente_femme_court;
    		$prix_produits[3][$i]=$prix_vente_femme_long;
    		$imgs_produits[$i]=$img_mini;
    		$descs_simples[$i]=$desc_simple;
     
    		$i++;
    	}
    }
     
    mysql_close($connect);
     
    //On transforme les tableaux en tableaux Javascript pour pouvoir les faire interpréter dans la fonction changement
    echo "<script type='text/javascript'>";
    construisTableauJS($refs_produits, "refs_produits_js");
    construisTableauJS($noms, "noms_js");
    construisTableauJS($descs_simples, "descs_produits_js");
    construisTableauJS($prix_produits, "prix_produits_js");
    echo "</script> ";
    ?>
     
     
     
    <form name="ajoutpanier">
    <table width="630" border="0" align="center" cellpadding="0" cellspacing="0">
     <tr> 
      <td width="58" align="center"><a href="javascript:changesexe('femme',prix_produits_js,refs_produits_js);"><img src="images/structure/symbole_femme.gif" width="43" height="63" border="0" /></a></td>
      <td width="55" align="center"><a href="javascript:changesexe('homme',prix_produits_js,refs_produits_js);"><img src="images/structure/symbole_homme.gif" width="43" height="63" border="0" /></a></td>
      <td width="50" rowspan="2" align="center"><p class="verdaNoir01">t-shirt<br />noir<br />ou<br />blanc</p></td>
      <td width="62" align="center"><a href="javascript:changecouleur('noir');"><img src="images/choix_tshirt/t-shirt-noir-V.gif" width="50" height="47" border="0" /></a></td>
      <td width="60" align="center"><a href="javascript:changecouleur('blanc');"><img src="images/choix_tshirt/t-shirt-blanc-V.gif" width="50" height="47" border="0" /></a></td>
     </tr>
     <tr align="center"> 
      <td width="58"><input type="radio" name="radiosexe" id="radiosexe1" value="femme"></td>
      <td><input type="radio" name="radiosexe" id="radiosexe2" value="homme" CHECKED></td>
      <td width="62" align="center"> <input type="radio" name="radiocouleur" id="radiocouleur1" value="noir"></td>
      <td width="60" align="center"> <input type="radio" name="radiocouleur" id="radiocouleur2" value="blanc" CHECKED></td>
     </tr>
    </table>
    </form>

  19. #19
    Membre habitué Avatar de avogadro
    Profil pro
    Inscrit en
    Mars 2006
    Messages
    412
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Mars 2006
    Messages : 412
    Points : 188
    Points
    188
    Par défaut
    ta un probleme avec ta fonction :
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    function changesexe(sexe,prix_produits_js,refs_produits_js)
    chez moi il met le message d'erreur prix_produit_js is not defined et je sais pas si cest a cause de ca mais cette fonction ( un peu modifiée avec des alert pour voir si ca passe dans la boucle ) ne fait aucuns alert, donc la fonction ne passe meme pas

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    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
    function changesexe(sexe,prix_produits_js,refs_produits_js){
    alert(sexe);
      var ref=document.getElementById('ref_produit').innerHTML;
      var id_tableau=rech_tableau(ref,refs_produits_js);
      if(sexe=="homme")
      {
        alert("homme");
        document.getElementById('cell').style.backgroundImage='url(images/structure/homme-blanc.gif)';
        ancien=document.getElementById('imagetshirt').src;
        nouveau=ancien.replace(/02.png/,"01.png");
    	document.getElementById('imagetshirt').src=nouveau;
     
    	document.getElementById('prix_produit').innerHTML=prix_produits_js[0][id_tableau];	
    	document.getElementById('radiosexe1').checked=true;		
      }
      else if(sexe=="femme")
      {
        alert("femme");
        document.getElementById('cell').style.backgroundImage='url(images/structure/femme-blanc.gif)';
        ancien=document.getElementById('imagetshirt').src;
        nouveau=ancien.replace(/02.png/,"01.png");
    	document.getElementById('imagetshirt').src=nouveau;
     
    	document.getElementById('prix_produit').innerHTML=prix_produits_js[2][id_tableau];
     
    	document.getElementById('radiosexe2').checked=true;
      }
    }
    curieux ^^

    j'ai donc ajouté
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
     var prix_produits_js;
     var refs_produits_js;
    tout en haut histoire de voir les changement et là, les alert s'affichent...

    puis en décalant le alert vers le bas on peu voir ce qui cloche, et la ils ne s'affichent plus :

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    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
    function changesexe(sexe,prix_produits_js,refs_produits_js){
      var ref=document.getElementById('ref_produit').innerHTML;
      var id_tableau=rech_tableau(ref,refs_produits_js);
      if(sexe=="homme")
      {    
        document.getElementById('cell').style.backgroundImage='url(images/structure/homme-blanc.gif)';
        ancien=document.getElementById('imagetshirt').src;
        nouveau=ancien.replace(/02.png/,"01.png");
    	document.getElementById('imagetshirt').src=nouveau;
     
    	document.getElementById('prix_produit').innerHTML=prix_produits_js[0][id_tableau];
    	alert("homme");	
    	document.getElementById('radiosexe1').checked=true;		
      }
      else if(sexe=="femme")
      {
     
        document.getElementById('cell').style.backgroundImage='url(images/structure/femme-blanc.gif)';
        ancien=document.getElementById('imagetshirt').src;
        nouveau=ancien.replace(/02.png/,"01.png");
    	document.getElementById('imagetshirt').src=nouveau;	
    	document.getElementById('prix_produit').innerHTML=prix_produits_js[2][id_tableau];
    	alert("femme");	
    	document.getElementById('radiosexe2').checked=true;
     
      }
    }
    Et perso a ce moment de la page j'ai 3 erreurs :



    Maintenant faut faire un peu de recherche... :s

    je met quand meme mon code :

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    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
    68
    69
    70
    71
    72
    73
    74
    75
    76
    77
    78
    79
    80
    81
    82
    83
    84
    85
    86
    87
    88
    89
    90
    91
    92
    93
    94
    95
    96
    97
    98
    99
    100
    101
    102
    103
    104
    105
    106
    107
    108
    109
    110
    111
    112
    113
    114
    115
    116
    117
    118
    119
    120
    121
    122
    123
    124
    125
    126
    127
    128
    129
    130
    131
    132
    133
    134
    135
    136
    137
    138
    139
    140
    141
    142
    143
    144
    145
    146
    147
    148
    149
    150
    151
    152
    153
    154
    155
    156
    157
    158
    159
    160
    161
    162
    163
    164
    165
    166
    167
    168
    169
    170
    171
    172
    173
    174
    175
    176
    177
    178
    179
    180
    181
    182
    183
    184
    185
    186
    187
    188
    189
    190
    191
    192
    193
    194
    195
    196
    197
    198
    199
    200
    201
    202
    203
    204
    205
    206
    207
    208
    209
    210
    211
    212
    213
    214
    215
    216
    217
    218
    219
    220
    221
    222
    223
    224
    225
    226
    227
    228
    229
    230
    231
    232
    233
    234
    235
    236
    237
    238
    239
    240
    241
    242
    243
    244
    245
    246
    247
    248
    249
    250
    251
    252
    253
    254
    255
    256
    257
    258
    259
    260
    261
    262
    263
    264
    265
    266
    267
    268
    269
    270
    271
    272
    273
    274
    275
    276
    277
    278
    279
    280
    281
    282
    283
    284
    285
    286
    287
    288
    289
    290
    291
    292
    293
    294
    295
    296
    297
    298
    299
    300
    301
    302
    303
    304
    305
    306
    307
    308
    309
    310
    311
    312
    313
    314
    315
    316
    317
    318
    319
    320
    321
    322
    323
    324
    325
    326
    327
    328
    329
    330
    331
    332
    333
    334
    335
    336
    337
    338
    339
    340
    341
    342
    343
    344
    345
    346
    347
    348
    349
    350
    351
    352
    353
    354
    355
    356
    357
    358
    359
    360
    361
    362
    363
    364
    365
    366
    367
    368
    369
    370
    371
    372
    373
    374
    375
    376
    377
    378
    379
    380
    381
    382
    383
    384
    385
    386
    387
    388
    389
    390
    391
    392
    393
    394
    395
    396
    397
    398
    399
    400
    401
    402
    403
    404
    405
    406
    407
    408
    409
    410
    411
    412
    413
    414
    415
    416
    417
    418
    419
    420
    421
    422
    423
    424
    425
    426
    427
    428
    429
    430
    431
    432
    433
    434
    435
    436
    437
    438
    439
    440
    441
    442
    443
    444
    445
    446
    447
    448
    449
    450
    451
    452
    453
    454
    455
    456
    457
    458
    459
    460
    461
    462
    463
    464
    465
    466
    467
    468
    469
    470
    471
    472
    473
    474
    475
    476
    477
    478
    479
    480
    481
    482
    483
    484
    485
    486
    487
    488
    489
    490
    491
    492
    493
    494
    495
    496
    497
    498
    499
    500
    501
    502
    503
    504
    505
    506
    507
    508
    509
    510
    511
    512
    513
    514
    515
    516
    517
    518
    519
    520
    521
    522
    523
    524
    525
    526
    527
    528
    529
    530
    531
    532
    533
    534
    535
    536
    537
    538
    539
    540
    541
    542
    543
    544
    <head>
    <title>t-shirt</title>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
     
     
    <!-- script pour le changement de couleur des Textes-->
    <script language=JavaScript>
     var prix_produits_js;
     var refs_produits_js;
     
    function coultshirt(couleur){
    document.getElementById('cell').style.backgroundColor=couleur;
    }
     
    function changecouleur(couleur){
      var a=document.getElementById('cell').style.backgroundImage;
      if((a=="url(images/structure/homme-blanc.gif)")||(a=="url(images/structure/homme-noir.gif)"))
      {
      	if(couleur=="blanc")
      	{
        	document.getElementById('cell').style.backgroundImage='url(images/structure/homme-blanc.gif)';
        	ancien=document.getElementById('imagetshirt').src;
    		nouveau=ancien.replace(/02.png/,"01.png");
    		document.getElementById('imagetshirt').src=nouveau;
    		document.getElementById('radiocouleur2').checked=true;
      	}
      	else if(couleur=="noir")
      	{
        	document.getElementById('cell').style.backgroundImage='url(images/structure/homme-noir.gif)';
        	ancien=document.getElementById('imagetshirt').src;
    		nouveau=ancien.replace(/01.png/,"02.png");
    		document.getElementById('imagetshirt').src=nouveau;
    		document.getElementById('radiocouleur1').checked=true;
      	}
      }
      else if((a=="url(images/structure/femme-blanc.gif)")||(a=="url(images/structure/femme-noir.gif)"))
      {
    	if(couleur=="blanc")
      	{
        	document.getElementById('cell').style.backgroundImage='url(images/structure/femme-blanc.gif)';
        	ancien=document.getElementById('imagetshirt').src;
        	nouveau=ancien.replace(/02.png/,"01.png");
    		document.getElementById('imagetshirt').src=nouveau;
    		document.getElementById('radiocouleur2').checked=true;
      	}
      	else if(couleur=="noir")
      	{
        	document.getElementById('cell').style.backgroundImage='url(images/structure/femme-noir.gif)';
        	ancien=document.getElementById('imagetshirt').src;
    		nouveau=ancien.replace(/01.png/,"02.png");
    		document.getElementById('imagetshirt').src=nouveau;
    		document.getElementById('radiocouleur1').checked=true;
      	}
      }
    }
     
    function rech_tableau(chaine,tab){
      var index_du_tableau=-1;
      for(elt in tab)
      {
        index_du_tableau++;
        if(tab[elt]==chaine)
    	{
    	  return index_du_tableau;
    	}
      }
      index_du_tableau=-1;
      return index_du_tableau;
    }
     
    function changesexe(sexe,prix_produits_js,refs_produits_js){
      var ref=document.getElementById('ref_produit').innerHTML;
      var id_tableau=rech_tableau(ref,refs_produits_js);
      if(sexe=="homme")
      {    
        document.getElementById('cell').style.backgroundImage='url(images/structure/homme-blanc.gif)';
        ancien=document.getElementById('imagetshirt').src;
        nouveau=ancien.replace(/02.png/,"01.png");
    	document.getElementById('imagetshirt').src=nouveau;
    	document.getElementById('radiosexe1').checked=true;	
    	document.getElementById('prix_produit').innerHTML=prix_produits_js[0][id_tableau];
    	alert("homme");	
     
      }
      else if(sexe=="femme")
      {
     
        document.getElementById('cell').style.backgroundImage='url(images/structure/femme-blanc.gif)';
        ancien=document.getElementById('imagetshirt').src;
        nouveau=ancien.replace(/02.png/,"01.png");
    	document.getElementById('imagetshirt').src=nouveau;	
    	document.getElementById('radiosexe2').checked=true;
    	document.getElementById('prix_produit').innerHTML=prix_produits_js[2][id_tableau];
    	alert("femme");	
     
     
      }
    }
     
    function changement(refs_produits_js,noms_js,descs_produits_js,prix_produits_js,indice_rand)
    {
    	if((indice_rand=="0")||(indice_rand=="1")||(indice_rand=="2"))
    	{
    		id_tableau=indice_rand;	
    	}
    	else
    	{
    		id_tableau=document.getElementById('choixTextes').options[document.getElementById('choixTextes').selectedIndex].value;
    	}
    	var test_coul_image=document.getElementById('imagetshirt').src;
    	if(test_coul_image.search("01.png")!=-1)
    	{
    		coul="01.png";
    	}
    	else
    	{
    		coul="02.png";
    	}
    	document.getElementById('imagetshirt').src='images/produits/'+refs_produits_js[id_tableau]+coul;
     
    	document.getElementById('nom_produit').innerHTML='Texte : '+noms_js[id_tableau];
    	document.getElementById('desc_produit').innerHTML=descs_produits_js[id_tableau];
    	document.getElementById('ref_produit').innerHTML=refs_produits_js[id_tableau];
    	var testprix=document.getElementById('cell').style.backgroundImage;
    	if(testprix.search("homme")!=-1)
    	{
    		document.getElementById('prix_produit').innerHTML=prix_produits_js[0][id_tableau];
    	}
    	else
    	{
    		document.getElementById('prix_produit').innerHTML=prix_produits_js[2][id_tableau];
    	}
    }
    </script>
     
    <!-- feuille de style des polices-->
    <style>
    .verdaNoir01 {
    color: #000000;
    	font-family: Verdana, Arial, Helvetica, sans-serif;
    	font-size: 11px;
    }
    .verdaNoir02 {
    color: #000000;
    	font-family: Verdana, Arial, Helvetica, sans-serif;
    	font-size: 14px;
    }
    .arialNoirCouleurs {
    color: #000000;
    	font-family: Arial, Helvetica, sans-serif;
    	font-size: 10px;
    }
    .verdaRose02 {
    color: #ED145B;
    	font-family: Verdana, Arial, Helvetica, sans-serif;
    	font-size: 14px;
    }
    .verdaRosePrix {
    color: #ED145B;
    	font-family: Arial, Helvetica, sans-serif;
    	font-size: 30px;
    	font-weight: bold;
    }
    .style_ref {
    font-size: 11px;
    font-family: Verdana, Arial, Helvetica, sans-serif;
    color: #ED145B;	
    }
    </style>
    </head>
     
    <?
    //Pour transmettre le tableau a la fonction changement il faut le transformer en tableau JS
    function construisTableauJS($tableauPHP, $nomTableauJS){
       echo $nomTableauJS." = new Array();";
       for($i = 0; $i < count($tableauPHP); $i++){
          if(!is_array($tableauPHP[$i])){
             echo $nomTableauJS."[".$i."] = '".$tableauPHP[$i]."';";
          }
          else{
             construisTableauJS($tableauPHP[$i], $nomTableauJS."[".$i."]");
          }
       }
       return;
    }
     
    include("connection_bdd.php");
    // Connexion à la BDD
    $connect = @mysql_connect($host,$user,$password);
    $select_base=@mysql_selectdb($base);
     
    // Tests de connexion
    if (!$select_base)
    {
        echo "<font color=\"#CC0000\"><b>Mauvaise configuration!!! </b></font><br>
    	Vérifiez que votre login et mot de passe sont bien saisi pour la connexion
    	à la base <b>$base</b>";
    	exit();
    }			
     
    if($souscat=="")
    {
    	$requete = "SELECT * FROM produit WHERE statut_produit!=0 AND num_categorie='01'";
    }
    else
    {
    	$requete = "SELECT * FROM produit WHERE statut_produit!=0 AND num_categorie='01' AND num_sous_categorie='$souscat'";
    }
    $result = mysql_query($requete);
     
    $nb_resultat=mysql_num_rows($result);
    if($nb_resultat==0)
    {
      echo "Aucun résultat trouvé!";
      exit();
    }
    else
    {
    	$i=0;
    	while ($row = mysql_fetch_array($result))
    	{						
    		$id_produit = $row["id_produit"];
    		$ref_produit = $row["reference_produit"];
    		$ref_fournisseur = $row["ref_chez_fournisseur"];
    		$marque = $row["marque"];
    		$logo_marque = $row["logo_marque"];
    		$nom_produit = $row["nom_produit"];
    		$prix_achat_homme_court = $row["prix_achat_homme_court"];
    		$prix_achat_homme_long = $row["prix_achat_homme_long"];
    		$prix_achat_femme_court = $row["prix_achat_femme_court"];
    		$prix_achat_femme_long = $row["prix_achat_femme_long"];
    		$prix_vente_homme_court = $row["prix_vente_homme_court"];
    		$prix_vente_homme_long = $row["prix_vente_homme_long"];
    		$prix_vente_femme_court = $row["prix_vente_femme_court"];
    		$prix_vente_femme_long = $row["prix_vente_femme_long"];
    		$prix_promo = $row["prix_promo"];
    		$poids = $row["poids"];
    		$img_mini = $row["img_mini"];
    		$img_prod = $row["img_prod"];
    		$statut_produit = $row["statut_produit"];
    		$num_categorie = $row["num_categorie"];
    		$num_sous_categorie = $row["num_sous_categorie"];
    		$desc_simple = $row["desc_simple"];
    		$desc_long = $row["desc_long"];
    		$type_produit = $row["type_produit"];
     
    		if($prix_promo!=0)
    		{
    			$prix_vente_homme_court=$prix_promo;
    			$prix_vente_homme_long=$prix_promo;
    			$prix_vente_femme_court=$prix_promo;
    			$prix_vente_femme_long=$prix_promo;
    		}
    		$ids_produits[$i]=$id_produit;
    		$refs_produits[$i]=$ref_produit;
    		$noms[$i]=$nom_produit;
    		$prix_produits[0][$i]=$prix_vente_homme_court;
    		$prix_produits[1][$i]=$prix_vente_homme_long;
    		$prix_produits[2][$i]=$prix_vente_femme_court;
    		$prix_produits[3][$i]=$prix_vente_femme_long;
    		$imgs_produits[$i]=$img_mini;
    		$descs_simples[$i]=$desc_simple;
     
    		$i++;
    	}
    }
     
    mysql_close($connect);
     
    //On transforme les tableaux en tableaux Javascript pour pouvoir les faire interpréter dans la fonction changement
    echo "<script type='text/javascript'>";
    construisTableauJS($refs_produits, "refs_produits_js");
    construisTableauJS($noms, "noms_js");
    construisTableauJS($descs_simples, "descs_produits_js");
    construisTableauJS($prix_produits, "prix_produits_js");
    echo "</script> ";
    ?>
     
    <body bgcolor="#FFFFFF" leftmargin="0" topmargin="0" marginwidth="0" marginheight="0">
    <div align="center"> </div>
     
    <form name="ajoutpanier">
    <table width="630" border="0" align="center" cellpadding="0" cellspacing="0">
      <tr> 
        <td width="399" align="center"><img src="images/structure/cadre-coul-article.gif" width="630" height="34" /></td>
      </tr>
      <tr> 
        <td align="center" background="images/structure/cadre-new-middle.gif"> 
          <TABLE cellSpacing=0 width=610 align=center>
           <TBODY>
              <TR> 
    			<td style="background-color:#6699FF;background-image:url(images/structure/homme-blanc.gif);width:298px;height:450px" valign="top" id="cell">
    			  <table width="300" height="410" border="0" cellpadding="0" cellspacing="0">
                    <tr> 
                      <td height="170">&nbsp;</td>
                    </tr>
                    <tr> 
                      <td id="produit" height="106" align="center"><img src="images/produits/<?echo $refs_produits[0];?>01.png" id="imagetshirt" width="136" height="104" /></td>
                    </tr>
                    <tr> 
                      <td>&nbsp;</td>
                    </tr>
                  </table>
    			</TD>
                <TD width=306 align="center" valign="top"> <table width="300" height="360" border="0" align="center" cellpadding="0" cellspacing="0">
                    <tr align="center"> 
                      <td align="right" valign="top"> <p class="verdaRose02">Dites 
                          leurs vos 4 v&eacute;rit&eacute;s!</p></td>
                    </tr>
                    <tr align="center"> 
                      <td height="19" align="right" valign="top"><hr size="1" noshade></td>
                    </tr>
                    <tr align="center"> 
                      <td align="right" valign="top"> <table width="300" border="0" cellspacing="0" cellpadding="0">
                          <tr valign="bottom"> 
                            <td colspan="4"> <table width="300" border="0" cellspacing="0" cellpadding="0">
                                <tr> 
                                  <td colspan="4"><p class="verdaNoir01" id="nom_produit">Texte 
                                      : <?echo $noms[0];?></p></td>
                                </tr>
                                <tr> 
                                  <td colspan="4"><hr size="1" noshade></td>
                                </tr>
                                <tr> 
                                  <td width="186"><p class="verdaNoir01" id="desc_produit"><?echo $descs_simples[0];?></p></td>
                                  <td width="16"><img src="images/structure/fleche.gif" width="15" height="8" /></td>
                                  <td width="29" align="center"><p class="verdaNoir01">Ref.</p></td>
                                  <td width="69" align="center"><p class="style_ref" id="ref_produit"><?echo $refs_produits[0];?></p></td>
                                </tr>
                              </table></td>
                          </tr>
                          <tr> 
                            <td colspan="4"><hr size="1" noshade></td>
                          </tr>
                          <tr align="left"> 
                            <td colspan="4"> <table width="285" border="0" cellspacing="0" cellpadding="0">
                                <tr> 
                                  <td width="58" align="center"><a href="javascript:changesexe('femme',prix_produits_js,refs_produits_js);"><img src="images/structure/symbole_femme.gif" width="43" height="63" border="0" /></a></td>
                                  <td width="55" align="center"><a href="javascript:changesexe('homme',prix_produits_js,refs_produits_js);"><img src="images/structure/symbole_homme.gif" width="43" height="63" border="0" /></a></td>
                                  <td width="50" rowspan="2" align="center"><p class="verdaNoir01">t-shirt<br />
                                      noir<br />
                                      ou<br />
                                      blanc</p></td>
                                  <td width="62" align="center"><a href="javascript:changecouleur('noir');"><img src="images/choix_tshirt/t-shirt-noir-V.gif" width="50" height="47" border="0" /></a></td>
                                  <td width="60" align="center"><a href="javascript:changecouleur('blanc');"><img src="images/choix_tshirt/t-shirt-blanc-V.gif" width="50" height="47" border="0" /></a></td>
                                </tr>
                                <tr align="center"> 
                                  <td width="58"><input type="radio" name="radiosexe" id="radiosexe1" value="femme"></td>
                                  <td><input type="radio" name="radiosexe" id="radiosexe2" value="homme" CHECKED></td>
                                  <td width="62" align="center"> <input type="radio" name="radiocouleur" id="radiocouleur1" value="noir"></td>
                                  <td width="60" align="center"> <input type="radio" name="radiocouleur" id="radiocouleur2" value="blanc" CHECKED></td>
                                </tr>
                              </table></td>
                          </tr>
                          <tr> 
                            <td colspan="4"><hr size="1" noshade></td>
                          </tr>
                          <tr align="center"> 
                            <td colspan="3"> <select name="select2" style="background-color:#dadada">
                                <option selected>--Tailles--</option>
                                <option>S ou 36</option>
                                <option>M ou 40</option>
                                <option>L ou 42</option>
                                <option>XL ou 44</option>
                              </select> </td>
                            <td width="158"><select name="select_sous_cat" id="select_sous_cat" style="background-color:#dadada" onChange="location.href='index.php?cat=01&souscat='+document.getElementById('select_sous_cat').options[document.getElementById('select_sous_cat').selectedIndex].value ">
                                <option selected>--Th&ecirc;mes--</option>
                                <option value="01">je deteste...</option>
                                <option value="02">la famille...</option>
                                <option value="03">moi je...</option>
                                <option value="04">les $...</option>
                                <option value="05">divers...</option>
                              </select></td>
                          </tr>
                          <tr> 
                            <td colspan="4"><hr size="1" noshade></td>
                          </tr>
                          <tr valign="bottom"> 
                            <td width="74" align="center" valign="middle"> <p class="verdaRosePrix" id="prix_produit"><?echo $prix_produits[0][0];?></p></td>
                            <td width="75" align="left" valign="middle"> <p class="verdaNoir01">Euros 
                                ttc</p></td>
                            <td width="151" colspan="2" align="right"><font color="#990000" size="6" face="Verdana, Arial, Helvetica, sans-serif"><font color="#6A0003" size="3"><strong><img src="images/structure/commander.gif" width="150" height="24" /></strong></font></font></td>
                          </tr>
                          <tr> 
                            <td colspan="4" align="left" valign="middle"><hr size="1" noshade></td>
                          </tr>
                          <tr align="center"> 
                            <td colspan="4" valign="middle"> <font color="#ED145B" size="3" face="Verdana, Arial, Helvetica, sans-serif"> 
                              <strong>Vous avez le choix parmis :</strong> </font> 
                            </td>
                          </tr>
                          <tr align="center" valign="bottom"> 
                            <td colspan="4"><img src="images/structure/black_comment.gif" width="19" height="17" /> 
                              <select name="choixTextes" id="choixTextes" style="background-color:#dadada" onChange="javascript:changement(refs_produits_js,noms_js,descs_produits_js,prix_produits_js);">
                                <option selected>tous les textes suivants...</option>
                                <?
    							for($j=0;$j<$nb_resultat;$j++)
    							{
    								echo "<option value='$j'>$noms[$j]</option>";
    							}
    							?>
                              </select> </td>
                          </tr>
                          <?
    					  // Connexion à la BDD
    					  $connect = @mysql_connect($host,$user,$password);
                          $select_base=@mysql_selectdb($base);
     
    					  // Tests de connexion
    					  if (!$select_base)
      					  {
    					    echo "<font color=\"#CC0000\"><b>Mauvaise configuration!!! </b></font><br>
    						Vérifiez que votre login et mot de passe sont bien saisi pour la connexion
    						à la base <b>$base</b>";
    						exit();
    					  }			
     
    					  if($souscat=="")
    					  {
    					  	$requete = "SELECT * FROM produit WHERE statut_produit!=0 AND num_categorie='01' ORDER BY RAND() LIMIT 3";
    					  }
    					  else
    					  {
    						$requete = "SELECT * FROM produit WHERE statut_produit!=0 AND num_categorie='01' AND num_sous_categorie='$souscat' ORDER BY RAND() LIMIT 3";
    					  }
    					  $result = mysql_query($requete);
    					  $nb_resultat=mysql_num_rows($result);
    					  if($nb_resultat==0)
    					  {
    					    echo "Aucun résultat trouvé!";
    						exit();
    					  }
    					  else
    					  {
    					  	$i=0;
    						while ($row = mysql_fetch_array($result))
    						{
    							$id_produit_rand = $row["id_produit"];
    							$ref_produit_rand = $row["reference_produit"];
    							$nom_produit_rand = $row["nom_produit"];
    							$prix_vente_homme_court_rand = $row["prix_vente_homme_court"];
    							$prix_vente_homme_long_rand = $row["prix_vente_homme_long"];
    							$prix_vente_femme_court_rand = $row["prix_vente_femme_court"];
    							$prix_vente_femme_long_rand = $row["prix_vente_femme_long"];
    							$prix_promo_rand = $row["prix_promo"];
    							$desc_simple_rand = $row["desc_simple"];
    							if($prix_promo_rand!=0)
    							{
    								$prix_vente_homme_court_rand=$prix_promo_rand;
    								$prix_vente_homme_long_rand=$prix_promo_rand;
    								$prix_vente_femme_court_rand=$prix_promo_rand;
    								$prix_vente_femme_long_rand=$prix_promo_rand;
    							}
     
    							$ids_produits_rand[$i]=$id_produit_rand;
    							$refs_produits_rand[$i]=$ref_produit_rand;
    							$noms_rand[$i]=$nom_produit_rand;
    							$prix_produits_rand[0][$i]=$prix_vente_homme_court_rand;
    							$prix_produits_rand[1][$i]=$prix_vente_homme_long_rand;
    							$prix_produits_rand[2][$i]=$prix_vente_femme_court_rand;
    							$prix_produits_rand[3][$i]=$prix_vente_femme_long_rand;
    							$descs_simples_rand[$i]=$desc_simple_rand;
     
    							$i++;
    						}
    					  }
    					  mysql_close($connect);
     
    					  //On transforme les tableaux en tableaux Javascript pour pouvoir les faire interpréter dans la fonction changement
    					  echo "<script type='text/javascript'>";
    					  construisTableauJS($refs_produits_rand, "refs_produits_rand_js");
    					  construisTableauJS($noms_rand, "noms_rand_js");
    					  construisTableauJS($descs_simples_rand, "descs_produits_rand_js");
    					  construisTableauJS($prix_produits_rand, "prix_produits_rand_js");
    					  echo "</script> ";
    					  ?>
                          <tr align="left"> 
                            <td colspan="4" valign="middle"><p class="verdaRose02"><a onClick="javascript:changement(refs_produits_rand_js,noms_rand_js,descs_produits_rand_js,prix_produits_rand_js,0);">Ex : <?echo $noms_rand[0];?></a></p></td>
                          </tr>
                          <tr align="left"> 
                            <td colspan="4" valign="middle"><p class="verdaRose02"><a onClick="javascript:changement(refs_produits_rand_js,noms_rand_js,descs_produits_rand_js,prix_produits_rand_js,1);">Ex : <?echo $noms_rand[1];?></a></p></td>
                          </tr>
                          <tr align="left"> 
                            <td colspan="4" valign="middle"><p class="verdaRose02"><a onClick="javascript:changement(refs_produits_rand_js,noms_rand_js,descs_produits_rand_js,prix_produits_rand_js,2);">Ex : <?echo $noms_rand[2];?></a></p></td>
                          </tr>
                          <tr align="right"> 
                            <td colspan="4" valign="middle"><p class="verdaNoir01"><br />
                                Largeur du texte : env. 20 cm / Frais de port : 5&euro;</p></td>
                          </tr>
                        </table></td>
                    </tr>
                  </table>
    			</TD>
              </TR>
              <TR> 
                <TD colspan="2" align="center">
    			  <hr size="1" noshade>
    			    <table width="593" height="22" border="0" align="center" cellpadding="0" cellspacing="0">
                      <tr align="center" valign="top">
                        <td width="120" rowspan="2" bgcolor="#FFFFFF"><p class="verdaNoir01">couleur texte</p></td>
                        <td width="40" bgcolor="#6699FF"><a href="javascript:coultshirt('#6699FF')"><img height=10 src="images/choix_tshirt/bt_couleur.gif" width=40 border=0 /></a></td>
                        <td width="40" bgcolor="#0033CC"><a href="javascript:coultshirt('#0033CC')"><img height=10 src="images/choix_tshirt/bt_couleur.gif" width=40 border=0 /></a></td>
                        <td width="40" bgcolor="#000066"><a href="javascript:coultshirt('#000066')"><img height=10 src="images/choix_tshirt/bt_couleur.gif" width=40 border=0 /></a></td>
                        <td width="40" bgcolor="#CC66CC"><a href="javascript:coultshirt('#CC66CC')"><img height=10 src="images/choix_tshirt/bt_couleur.gif" width=40 border=0 /></a></td>
                        <td width="40" bgcolor="#FF3300"><a href="javascript:coultshirt('#FF3300')"><img height=10 src="images/choix_tshirt/bt_couleur.gif" width=40 border=0 /></a></td>
                        <td width="40" bgcolor="#CC0000"><a href="javascript:coultshirt('#CC0000')"><img height=10 src="images/choix_tshirt/bt_couleur.gif" width=40 border=0 /></a></td>
                        <td width="40" bgcolor="#FFFF00"><a href="javascript:coultshirt('#ffff00')"><img height=10 src="images/choix_tshirt/bt_couleur.gif" width=40 border=0 /></a></td>
                        <td width="40" bgcolor="#999933"><a href="javascript:coultshirt('#999933')"><img height=10 src="images/choix_tshirt/bt_couleur.gif" width=40 border=0 /></a></td>
                        <td width="40" bgcolor="#999999"><a href="javascript:coultshirt('#999999')"><img height=10 src="images/choix_tshirt/bt_couleur.gif" width=40 border=0 /></a></td>
                        <td width="40" bgcolor="#00FF00"><a href="javascript:coultshirt('#00FF00')"><img height=10 src="images/choix_tshirt/bt_couleur.gif" width=40 border=0 /></a></td>
                        <td width="40" bgcolor="#000000"><a href="javascript:coultshirt('#000000')"><img height=10 src="images/choix_tshirt/bt_couleur.gif" width=40 border=0 /></a></td>
                        <td width="40" bgcolor="#ffffff"><a href="javascript:coultshirt('#ffffff')"><img height=10 src="images/choix_tshirt/bt_couleur.gif" width=40 border=0 /></a></td>
                    </tr>
                    <tr align="center">
    				  <td width="40"><p class="arialNoirCouleurs">ciel</p></td>
                      <td width="40"><p class="arialNoirCouleurs">bleu</p></td>
                      <td width="40"><p class="arialNoirCouleurs">marine</p></td>
                      <td width="40"><p class="arialNoirCouleurs">Rose</p></td>
                      <td width="40"><p class="arialNoirCouleurs">orange</p></td>
                      <td width="40"><p class="arialNoirCouleurs">rouge</p></td>
                      <td width="40"><p class="arialNoirCouleurs">jaune</p></td>
                      <td width="40"><p class="arialNoirCouleurs">or</p></td>
                      <td width="40"><p class="arialNoirCouleurs">argent</p></td>
                      <td width="40"><p class="arialNoirCouleurs">vert fluo</p></td>
                      <td width="40"><p class="arialNoirCouleurs">noir</p></td>
                      <td width="40"><p class="arialNoirCouleurs">blanc</p></td>
                    </tr>
                  </table>
    			</TD>
              </TR>
            </TBODY>
          </TABLE>
    	</td>
      </tr>
      <tr> 
        <td align="center"><img src="images/structure/cadre-new-footer.gif" width="630" height="36" /></td>
      </tr>
    </table>
    </form>
    <p class="verdaRose02"><br /></p>
    <p class="verdaRose02">&nbsp;</p>
    <p>&nbsp;</p>
    </body>
    </html>

Discussions similaires

  1. [PB 10.5][Débutant] Check bouton radio par défaut
    Par lanageuse59 dans le forum Powerbuilder
    Réponses: 1
    Dernier message: 18/02/2009, 18h02
  2. [CSS] modifier le style d'un bouton radio
    Par glloq8 dans le forum Mise en page CSS
    Réponses: 2
    Dernier message: 13/12/2006, 09h58
  3. checked le radio bouton par défaut
    Par arno49 dans le forum Struts 1
    Réponses: 2
    Dernier message: 20/09/2006, 19h23
  4. Déterminer le bouton radio checked
    Par cyberdevelopment dans le forum Langage
    Réponses: 8
    Dernier message: 25/07/2006, 16h36
  5. probleme bouton radio checked
    Par coachbob44 dans le forum Général JavaScript
    Réponses: 2
    Dernier message: 06/04/2005, 10h02

Partager

Partager
  • Envoyer la discussion sur Viadeo
  • Envoyer la discussion sur Twitter
  • Envoyer la discussion sur Google
  • Envoyer la discussion sur Facebook
  • Envoyer la discussion sur Digg
  • Envoyer la discussion sur Delicious
  • Envoyer la discussion sur MySpace
  • Envoyer la discussion sur Yahoo