dongmei8760 2013-04-04 22:36
浏览 74
已采纳

在joomla 2.5中自定义注册表单 - 根据单选按钮值动态启用字段

I want to customize joomla registration form. I ve added 2 text fields (company name, vat_number) and i ve created a radio button customerType with 2 options(business user, normal user).

Now all the fields are visible in the form. What i want is, when the user selects business user to enable the 2 text fields and when he selects normal user to disable them on the fly.

I guess i need to add javascript to the form. Can anyone help?

Thank you!

  • 写回答

2条回答 默认 最新

  • dongmiao260399 2013-04-05 05:11
    关注

    I have done this in here

    # Script to show hide div
    <script type="text/javascript">
        function show(obj) {
    
        if(obj == 'farmer')
        {
            document.getElementById('SkiDiv1').style.display = 'block';
            document.getElementById('SkiDiv2').style.display = 'none';
        }
    
        if(obj == 'landowner')
        {
            document.getElementById('SkiDiv2').style.display = 'block';
            document.getElementById('SkiDiv1').style.display = 'none';
        }
        if(obj == 0)
        {
            document.getElementById('SkiDiv2').style.display = 'none';
            document.getElementById('SkiDiv1').style.display = 'none';
        }
    
        }
        </script>
    
    # Selct from dropdown
    <select  name="siteusertype" class="inputbox1 required" onchange="show(this.value)">
        <option id="selectuser" value="0">Select User</option> 
        <option value="farmer">Are you a Farmer ?</option>
        <option value="landowner">Are you a Landowner ?</option>
    </select>
    
    # Both div with different IDs
    <div id="SkiDiv1"> User 1 field </div>
    <div id="SkiDiv2"> User 2 field </div>
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 Matlab怎么求解含参的二重积分?
  • ¥15 苹果手机突然连不上wifi了?
  • ¥15 cgictest.cgi文件无法访问
  • ¥20 删除和修改功能无法调用
  • ¥15 kafka topic 所有分副本数修改
  • ¥15 小程序中fit格式等运动数据文件怎样实现可视化?(包含心率信息))
  • ¥15 如何利用mmdetection3d中的get_flops.py文件计算fcos3d方法的flops?
  • ¥40 串口调试助手打开串口后,keil5的代码就停止了
  • ¥15 电脑最近经常蓝屏,求大家看看哪的问题
  • ¥60 高价有偿求java辅导。工程量较大,价格你定,联系确定辅导后将采纳你的答案。希望能给出完整详细代码,并能解释回答我关于代码的疑问疑问,代码要求如下,联系我会发文档