How can I use html to fire a toggle function written in javascript for both page load and when I click on the checkbox?
Essentially what the function does is toggle a certain input box for the user. I allow them to enter a custom price. I want this box to show by default, and also to be toggled. Am currently able to have just "onclick" work with this input but when I add the "onload" it does not load by default. Yes, I can still click it to toggle it.
<input
type="checkbox"
id="item_use_custom_price_<?php echo $_item->getId() ?>"
checked="checked"
onload="toggleCustPrice(order, this);"
onclick="toggleCustPrice(order, this);"
/>
I have the above input in a PHTML file (not really a php question). The ID is pulling from PHP there can be many rows for the grid.
I do not think I can use the window.onload() function because in my JS script because I need to be able to pass the "order" and "this" parameters into the function so the proper row toggles.