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 (标签-STM32|关键词-智能小车)
  • ¥20 关于#stm32#的问题,请各位专家解答!
  • ¥15 (标签-python)
  • ¥15 第一个已完成,求第二个做法
  • ¥20 搭建awx,试了很多版本都有错
  • ¥15 java corba的客户端该如何指定使用本地某个固定IP去连接服务端?
  • ¥15 activiti工作流问题,求解答
  • ¥15 有人写过RPA后台管理系统么?
  • ¥15 Bioage计算生物学年龄
  • ¥20 如何将FPGA Alveo U50恢复原来出厂设置哇?