Cannot Get Value Of Textarea With Shopify Product Options By Bold

- 1 answer

I'm trying to get the value of a textarea with Shopify Product Options by Bold and it is currently not working. I am able to get the value of a textarea locally, but I can not get the value when I move the code over to Shopify. I have looked here and here to no avail.

Here's the relevant code:

var textbox = document.getElementsByName("properties[Message Body]")[0].value;

and here's the textarea I'm trying to get the value of

<textarea data-option-key="ta_248832" id="248832" class="bold_option_child shapp_full_width " name="properties[Message Body]"></textarea>

When I try to run this on Shopify, I get an error saying "Uncaught TypeError: Cannot set property 'onkeyup' of null", although I did notice that at one point shopify runs the following jQuery code, which might be what's causing my problem:

jQuery('#248832').change(function (){conditional_rules(7437760391);})

I am trying to get the value of the textarea so I can run get the amount of words in said textarea.

Any help would be greatly appreciated!



Look to see if the element that is returned as null has loaded yet. Others in similar situations fixed this by loading the script last. Hope this is helpful :)