开发者

onchange same function multiple times

I have the below func开发者_如何学编程tion to use in onchange function. Can I use the same function for multiple times in the same form ?

<script type="text/javascript">      
    function showfield(name) {
        if (name === 'Other') {
            document.getElementById('div1').innerHTML = '<html:text name="reDataForm" property="member.accountNumber" styleClass="formContent"  maxlength="9" size="9"/>';
        } else {
            document.getElementById('div1').innerHTML = '';
        }
    }
</script>


The answer to your question, specifically, is yes. You can - and should - reuse code functions as much as possible. That is a core concept in programming - don't repeat yourself.

With that said, another important concept is to not be afraid to experiment. Rather than asking stackoverflow if you can reuse this function, you ought to have tried it yourself. You would have answered your own question before you had ever asked it! :)

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜