Post by zeroms » Tue Aug 14, 2012 3:48 am

Hi Guys,

I have a field for greeting card yes/no and would like to show greeting card message if the client opts to have a greetings card with their gift.

Is there an extension or a way I can hide the message box unless the gift card select is yes/true.

Thanks

New member

Posts

Joined
Mon Apr 16, 2012 4:46 pm
Location - UK

Post by Avvici » Tue Aug 21, 2012 4:52 am

Please do not post BUMPS. Your thread is being looked at. Sometimes it takes a while. I have amended the post.

User avatar
Expert Member

Posts

Joined
Tue Apr 05, 2011 12:09 pm
Location - Asheville, NC

Post by zeroms » Tue Aug 21, 2012 4:58 am

Apologies, I just need to nail this one to complete my website, I can do it in other carts I have used so wanted to see if anyone had an extension to do it :)

New member

Posts

Joined
Mon Apr 16, 2012 4:46 pm
Location - UK

Post by Avvici » Tue Aug 21, 2012 5:05 am

You have not really provided any detailed information to what version you are using or where in your Open Cart this shows up. However, just use jQuery to "show" the message box when the check box is checked. Hide the message box with CSS with style="display:none;"

Example of a hidden textarea field + jquery to reveal it:

Code: Select all

 <input type="checkbox" name="name" value="value" id="myCheckBox" />
         <textarea name="name" cols="40" rows="5" id="myTextArea" style="display:none;">Initial Value, if any</textarea>
           <script>$('#myCheckBox').bind('change',function(){
			
                 $('#myTextArea').show();
});
</script>

User avatar
Expert Member

Posts

Joined
Tue Apr 05, 2011 12:09 pm
Location - Asheville, NC

Post by zeroms » Tue Aug 21, 2012 6:18 am

Thank you very much, the options are part of the product options section on the products page (product.tpl)

I am using 1.5.2.1

How would I use your code with the option checkbox when these are dynamically created from the Options in the database please?

New member

Posts

Joined
Mon Apr 16, 2012 4:46 pm
Location - UK

Post by spottedhaggis » Thu Oct 18, 2012 7:40 pm

Hi

I am looking for something like this. I have 5 options on a product, and depending on what is selected in one of the options, I want to hide or show another of the options.

I can understand the response given, in the jquery would do this, but since the options are dynamic and created on the fly I do not see how this can be implemented on the tpl file in question.

Did you ever find a way to do this at all?

Active Member

Posts

Joined
Tue Jun 26, 2012 11:20 pm

Post by Avvici » Thu Oct 18, 2012 10:29 pm

Now you are taking about an array of options where each option set has an id. For example your select box option(s) will all have id's tied to them. As long as you have this you can do whatever you want with jQuery.

Example: (You could go inside of a radio button group option and compare the current selected radio button with the current echo'd value, all in jQuery)

Code: Select all

 <script>
        //set up the onclick event according to radio button ID.
         $('#option-value-'+'<?php echo $option_value['product_option_value_id']; ?>').bind('click', function() {
           
 //get current option_value_id
           var value = '<?php echo $option_value['product_option_value_id'];?>';
           
//set up a conditional to show/hide other elements on the page
            if(value == 120){
    
        $("#element1").show();
        $("#element2").hide();
    }else if(value == 121){
    
    $("#element3").show();
    $("#element4").hide();
     }else{
            
        $("#element1").hide();
        $("#element1").hide();
        $("#element3").hide(); 
        $("#element4").hide(); 
         
    
     }
});
          </script>

User avatar
Expert Member

Posts

Joined
Tue Apr 05, 2011 12:09 pm
Location - Asheville, NC

Post by spottedhaggis » Fri Oct 19, 2012 12:31 am

much to my own surprise, I actually understand what you have put, lol, but as it turns out it is no longer a requirement, too much work for just a single option, customer not bothered about it, however, perhaps you can help me with another issue, which would be a vast improvement for my customer at the very least.

http://forum.opencart.com/viewtopic.php?f=20&t=86904

Active Member

Posts

Joined
Tue Jun 26, 2012 11:20 pm

Post by spottedhaggis » Mon Oct 22, 2012 6:59 pm

ok, this is now back in the requested list again, sheesh, customers.

ok, my basic and limited understanding on opencart is that options are dynamic, so there is no actual hard code that can be edited that corelates with each of the individual options, so how would I embed this code to an option that is not in the actual code itself

Active Member

Posts

Joined
Tue Jun 26, 2012 11:20 pm

Post by antstyl » Mon Apr 22, 2013 2:26 am

Where do we have to put this code?
Can I have a little more help please?

User avatar
Active Member

Posts

Joined
Mon Nov 12, 2012 5:40 pm

Post by Avvici » Mon Apr 22, 2013 5:23 am

Have you checked the extension store for this? It would take developing. You need to hire someone, or purchase an extension

User avatar
Expert Member

Posts

Joined
Tue Apr 05, 2011 12:09 pm
Location - Asheville, NC

Post by rph » Mon Apr 22, 2013 8:02 am

I have Dependent Options which works with dropdown select-type options. There's also Product Configurator but I don't have any experience with it personally. Edit: Support is no longer offered for Product Configurator so it's probably not a good choice.

-Ryan


rph
Expert Member

Posts

Joined
Fri Jan 08, 2010 5:05 am
Location - Lincoln, Nebraska

Post by antstyl » Sat May 11, 2013 5:08 pm

avvici

please can you explain me what values should be changed to this code?

Code: Select all

 <input type="checkbox" name="name" value="value" id="myCheckBox" />
         <textarea name="name" cols="40" rows="5" id="myTextArea" style="display:none;">Initial Value, if any</textarea>
           <script>$('#myCheckBox').bind('change',function(){
         
                 $('#myTextArea').show();
});
</script>

User avatar
Active Member

Posts

Joined
Mon Nov 12, 2012 5:40 pm

Post by DougJoseph » Wed Mar 31, 2021 7:20 am

Thanks for the kind help, including great code templating. Great jquery idea. Thank you!

Newbie

Posts

Joined
Tue Mar 30, 2021 1:02 am
Who is online

Users browsing this forum: No registered users and 151 guests