I am new to prototype, so I guess this must be a common question. It is difficult to explain and also difficult to search for.
I start with the code - it should later become a javascript shopping cart: function purchase() { // get product var product = products.get(this.identify().sub('purchase', '')); if (this.checked) { cart.addProduct(product); Element.addClassName('purchase' + product.getCategory() + 'Area', 'areaGreen'); } else { cart.removeProduct(product); var removeAreaGreen = true; cart.getProducts().each(function(pair) { if (pair.value.getCategory() == product.getCategory()) { removeAreaGreen = false; } }); if (removeAreaGreen) Element.removeClassName('purchase' + product.getCategory() + 'Area', 'areaGreen'); } cart.refresh(); } function selectOption() { // get product var product = products.get(this.identify().sub('purchase', '').sub ('Options', '')); product.setActiveOption($(this.identify()).value); cart.refresh(); } // when the dom is fully loaded, execute these scripts document.observe("dom:loaded", function() { // initializing options // todo: find a way to init options and products // add event handlers $$('.modulePurchase .options').invoke('observe', 'change', selectOption).invoke('observe', 'keyup', selectOption); $$('.modulePurchase .purchase').invoke('observe', 'click', purchase); }); This works great so far. Elements with ('.modulePurchase .purchase') are simple checkbox input fields. Elements with ('.modulePurchase .options') are select boxes. My requirement now is that some of the elements are already checked during start of the page. So I want that the functions purchase and selectOptions should be called on any of the mentioned elements during start up of the page. The problem is there is no onload-Event for input fields. Also it is not possible to fire native events. I cannot do this: $$('.modulePurchase .options').invoke('selectOption'); because selectOption is not a function of Element. Do you have any ideas how I can solve this easily? --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Prototype & script.aculo.us" group. To post to this group, send email to prototype-scriptaculous@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/prototype-scriptaculous?hl=en -~----------~----~----~----~------~----~------~--~---