Advertisement
Guest User

Untitled

a guest
Apr 18th, 2014
62
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.55 KB | None | 0 0
  1. <input type="radio" checked="" value="PAR" name="marche">Particulier
  2. <input type="radio" value="PRO" name="marche">PRO/TPE
  3. <input type="radio" value="ENT" name="marche">Entreprise
  4.  
  5. <select id="typeDeProduit" name="typeDeProduit">
  6. <option class="PAR" value="21" style="display: block;">G9119A Mrh Gan Habitat Globale </option>
  7. <option class="PAR" value="22" style="display: block;">G9120A Mrh Gan Habitat Confort </option>
  8. <option class="PRO" value="24" style="display: none;">G6020A - RCCE </option>
  9. <option class="PRO" value="25" style="display: none;">G6006A - Autre RC </option>
  10. <option class="PRO" value="27" style="display: none;">G9001A - Stella (- de 10 M engagement et/ou -de 5 étoiles) </option>
  11. <option class="ENT" value="42" style="display: none;">G7009A - Dommages divers entreprise </option>
  12. <option class="ENT" value="43" style="display: none;">G2004A - Individuelles entreprise </option>
  13. <option class="PAR" value="6" style="display: block;">G4102A 2-3 roues (2 roues - Quad-Voiturette, …) </option>
  14. </select>
  15.  
  16. In jquery function :
  17.  
  18. $("input:radio[name=marche]").change(function(){
  19. cacherTousTypesDeProduit();
  20. rafraichirListeTypeDeProduit();
  21. });
  22.  
  23.  
  24. function cacherTousTypesDeProduit(){
  25. $("#typeDeProduit>option").hide();
  26. }
  27.  
  28. function rafraichirListeTypeDeProduit(){
  29. var typeDeProduitSelectionne = $("input:radio[name=marche]:checked").val();
  30. $("#typeDeProduit>option[class="+typeDeProduitSelectionne+"]").show();
  31. }
  32.  
  33. $("input:radio").on('change click',function(){
  34. $("select#typeDeProduit > option").hide().prop('disabled', false);
  35. cacherTousTypesDeProduit();
  36. rafraichirListeTypeDeProduit();
  37. });
  38.  
  39.  
  40. function cacherTousTypesDeProduit(){
  41. $("select#typeDeProduit > option").hide().prop('disabled', true);
  42. $("select#typeDeProduit").val('');
  43. }
  44.  
  45. function rafraichirListeTypeDeProduit(){
  46. var typeDeProduitSelectionne = $("input:radio[name=marche]:checked").val();
  47. console.log(typeDeProduitSelectionne);
  48. $("#typeDeProduit > option[class="+typeDeProduitSelectionne+"]").hide().prop('disabled', false);
  49. }
  50.  
  51. $("input:radio[name=marche]").change(function () {
  52. cacherTousTypesDeProduit();
  53. rafraichirListeTypeDeProduit();
  54. });
  55.  
  56.  
  57. function cacherTousTypesDeProduit() {
  58. $("#typeDeProduit>option").hide();
  59. }
  60.  
  61. function rafraichirListeTypeDeProduit() {
  62. var typeDeProduitSelectionne = $("input:radio[name=marche]:checked").val();
  63. //auto select the first option
  64. $("#typeDeProduit>option[class=" + typeDeProduitSelectionne + "]").show().first().prop('selected', true);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement