Within our online store, some products feature a yForm to consolidate various parts of the product. Is there a straightforward method to automatically transfer the sum field value to another field, such as the product quantity (which does not use yForm)? It seems like I'll need to use JavaScript for this task, but the generated ID for the sumfield is unknown to me, making it challenging to retrieve the sum. Additionally, my JavaScript skills are somewhat limited...
UPDATE:
To retrieve the value, I am utilizing the following code snippet:
copyYFormValueToProductQuantity : function() {
var copyText = document.querySelector('input[id*="sum"]').value
if (copyText > 0 && copyText != null)
{
//carry out the necessary actions
}
console.log("Copied value: " + copyText)
},
However, this particular line
document.querySelector('input[id*="sum"]').value
is returning null. Even when I try it in the browser console, it still returns null. Strangely, after inspecting the element, it does work and provides the desired value. I suspect I may be overlooking some fundamental JS concepts, and the object may not be fully loaded before attempting to retrieve the value?
By the way, I am triggering this function with a keydown event listener.