From 7124965ba8e68268f61b3126164b58710aa7f999 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Chai=CC=88b=20Martinez?= Date: Tue, 12 Feb 2019 18:52:55 +0100 Subject: [PATCH] Add JS script --- app/views/support/index.html.haml | 63 ++++++++++++++++++++++++++++++- 1 file changed, 61 insertions(+), 2 deletions(-) diff --git a/app/views/support/index.html.haml b/app/views/support/index.html.haml index ac566f292..1f8bbbacb 100644 --- a/app/views/support/index.html.haml +++ b/app/views/support/index.html.haml @@ -6,7 +6,7 @@ .description Contactez-nous via ce formulaire et nous vous répondrons dans les plus brefs délais. - Pensez bien à nous donner le plus d'informations possible pour que nous puissions vous aider au mieux. + Pensez bien à nous donner le plus d'informations possible pour que nous puissions vous aider au mieux = form_tag contact_path, method: :post, multipart: true, class: 'form' do |f| - if !logged_in? @@ -20,7 +20,24 @@ = label_tag :type do Votre problème %span.mandatory * - = select_tag :type, options_for_select(@options, params[:type]) + = select_tag :type, options_for_select(@options, params[:type]),include_blank:"Choisir un problème", onchange:"show()" + + + #info_demarche.contact-champ.aidesupport.hide + Mon texte info_demarche + %br + %br + + #usager_perdu.contact-champ.aidesupport.hide + Mon texte usager_perdu + %br + %br + + #info_instruction.contact-champ.aidesupport.hide + Mon texte info_instruction + %br + %br + .contact-champ = label_tag :dossier_id, 'Numéro du dossier concerné' @@ -46,3 +63,45 @@ .send-wrapper = button_tag 'Envoyer le message', type: :submit, class: 'button send primary' + + :javascript + function show(){ + var e = document.getElementById ("type"); + var choix = e.options [e.selectedIndex] .value; + var divid = choix.replace(' ','_'); + var div_info_demarche = document.getElementById("info_demarche"); + var div_usager_perdu_ = document.getElementById("usager_perdu"); + var div_info_instruction = document.getElementById("info_instruction"); + + + console.log(divid); + switch (divid) { + case 'info_demarche': + console.log('info_demarche'); + document.getElementById("info_demarche").classList.add("show"); + + break; + + case 'usager_perdu': + console.log('usager_perdu'); + document.getElementById("usager_perdu").classList.add("show"); + + break; + + case 'info_instruction': + console.log('info_instruction'); + document.getElementById("info_instruction").classList.add("show"); + + break; + + default: + console.log('defaut'); + + } + + + + + + } +