Note field appear when checkbox button is checked in cart

Solved
Highlighted
Excursionist
18 1 0

I would like to add a checbox button that shows a note field when checked.

 

I am not sure how do to this...

 

I tried this code, but nothing happens when the checkbox is checked.

 

Any ideas?

 

<div>
<input type="checkbox" name="attributes[exclude invoice]" id="note-trigger" value="1" unchecked="unchecked" />
<label for="exclude invoice">Include Gift Message</label>
<div id="note-wrap" style="display:none;">
<textarea name="note" id="note" rows="3" cols="60"></textarea>
</div>
</div>

0 Likes
Highlighted

Success.

Shopify Expert
2902 497 665

For that you need Jquery code to hide an dhow field base on checkbox you cant do it by just html code;

Add this code in Asset->theme.js file bottom:

$(document).on('click','#note-trigger',function(){
    $('#note-wrap').hide();
    if($(this).is('checked')){
        $('#note-wrap').show();
    }
})
Want to modify or custom changes on store hire me.
If helpful then please Like and Accept Solution.
Email: jasoliyabrijesh123@gmail.com
Skype: jasoliya.brijesh
Want to get Free review and advice for sale on store ?? just text me here
1 Like
Highlighted

Success.

Excursionist
18 1 0

Thank you so much!!

 

I knew I needed the Jquery code somewhere, I just didn't know where to put it! The code you sent didn't work properly, but this did work:

 

$(document).ready(function() {

$('#note-trigger').change(function() {

$('#note-wrap').slideToggle('500');

});

});

 

I'm curious, will this info be passed on with the order details on the back end, for me to see the gift message when the order is fulfilled?

0 Likes
Highlighted
Shopify Expert
2902 497 665

When user enter text in textarea it will auto pass to order note field.

You have already used this:

<textarea name="note" id="note" rows="3" cols="60"></textarea>
Want to modify or custom changes on store hire me.
If helpful then please Like and Accept Solution.
Email: jasoliyabrijesh123@gmail.com
Skype: jasoliya.brijesh
Want to get Free review and advice for sale on store ?? just text me here
0 Likes
Excursionist
18 1 0

Thank you so much, started coding yesterday LOL!

0 Likes