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 对于知识的学以致用的解释
  • ¥50 三种调度算法报错 有实例
  • ¥15 关于#python#的问题,请各位专家解答!
  • ¥200 询问:python实现大地主题正反算的程序设计,有偿
  • ¥15 smptlib使用465端口发送邮件失败
  • ¥200 总是报错,能帮助用python实现程序实现高斯正反算吗?有偿
  • ¥15 对于squad数据集的基于bert模型的微调
  • ¥15 为什么我运行这个网络会出现以下报错?CRNN神经网络
  • ¥20 steam下载游戏占用内存
  • ¥15 CST保存项目时失败