开发者

Magento - Javascript: update form from user's choice

I'm writing a form for a custom module and I want to show/hide some fields according to which radio is checked, kind of like what happens when you select a payment method in the onepage checkout and a description appears.

Before I start writing the js code, I took a look at js/varien/form.js to see if I could use an already existing function, but the truth is my js skills aren't enough to really understand what I'm looking at.

So my question is, is there something I can use? Which method and how can I trigger it?

I'm gonna review onepage checkout's code in order to see if it makes things clearer, but if you know another form that has this behaviour please let开发者_开发问答 me know.

Also, I know how I could write such code in plain javascript, but I'd rather use the magento way, in order to learn.

Cheers


The Javascript code doing is defined in [skin]/js/opcheckout.js. The Payment class defined there is made solely for the credit card checkout form.

You can study what they did and do something similar - or just write the show/hide code yourself. I'd suggest the latter if you don't have an insane amount of programmic logic - otherwise wrap it in a class.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜