duanjiao8007 2012-12-12 10:50 采纳率: 100%
浏览 85
已采纳

表单输入字段的动态扩展

I have been working on a web-based device management system for work, and I have ran into an issue with presenting the user the option of adding more fields as needed. For example, some devices will have say 4x drives, 6x ram modules, etc. My options so far are...

  • Hard-code the MySQL Database to have X amount of each type of field. 4 disk drive fields, 6 ram module fields, etc. However, most machines will have less than this, and some may have considerably more.

  • Create a table for each type that will possibly have more than one
    value. Such as a device_drives table, device_memory table, etc.

Would there be a more efficient (and dynamic) method of doing this? Both methods I have considered seem pretty silly. Here is a visual example of it, the red arrows representing icons that the user could click to add another of that type.

enter image description here

  • 写回答

1条回答 默认 最新

  • duanri1985 2012-12-12 11:13
    关注

    Why does it sound silly? Let's say you have one hundred million items in database. Do you alter that table every time a new field type is added? Does that sound smart?

    I would suggest another solution. You could create a table for field types and another table for field values. This way you can separate the configuration data from the device data, which can be a good idea. No matter how many field types a device has, how many values every field has or in case of addition of a field type or value, you are still safe with this architecture.

    As for visual creating of fields, you can simply add "+" at the right side, which is click-able and creates another similar field under the current one.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 基于OPENCV的人脸识别
  • ¥20 51单片机学习中的问题
  • ¥30 Windows Server 2016利用兩張網卡處理兩個不同網絡
  • ¥15 Python中knn问题
  • ¥15 使用C#,asp.net读取Excel文件并保存到Oracle数据库
  • ¥15 C# datagridview 单元格显示进度及值
  • ¥15 thinkphp6配合social login单点登录问题
  • ¥15 HFSS 中的 H 场图与 MATLAB 中绘制的 B1 场 部分对应不上
  • ¥15 如何在scanpy上做差异基因和通路富集?
  • ¥20 关于#硬件工程#的问题,请各位专家解答!