Jump to content

jQuery show/hide on change selection option (almost working)

Recommended Posts

so, me and a friend have this website:

Currently, im adding CUSTOM JS to the PrestaShop via this file here:


At the very bottom of the file, beneath the comment (Product Normal/Family Size on Product Details Page - Show/Hide on change) i have this code here:

$(function () {
  // "29" == (Normal Size)
  // #an_productfields_1_id == (Normal Size)
  // "30" == (Family Size)
  // #an_productfields_2_id == (Family Size)
  // #group_6 == SELECTION/DropDown Form Box

  //$("#an_productfields_1_id").hide(); // Normal Size (hide instantly)
  //$("#an_productfields_2_id").hide(); // Family Size (hide instantly)
  $("#group_6").change(function () {
    if ($("#group_6").val() == "29") {
      // Normal Size
    } else {
    if ($("#group_6").val() == "30") {
      // Family Size
    } else {

and i almost got it working, however! As u try it on the website, and i for example take the (Almindelig) value from the select box, it dosent shows the very first time... but when i change to Family Size, nothing happens on the second choise! And same goes for the other way around. When i select (Familie) on first try, it works, hides the "normal sizes / almindelig", and shows family...

any ideas as to why it does this? I should have used the propper code i think... i got a peace of the code form this linke by searching google:



If you could possibly tell me what im doing wrong and what i could do in future cases, i would be very happy!

Also, i did consider using "toggle" from jQuery, but not sure hos to use that just yet so i went with this option since i got the most experience (so to speak) with this one...

in anyways, i hope you guys can help me out, as always! :D

Thanks in advance!

Looking foreword for a reply... very... VERY... patiently ;)

Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Create New...