如何在mysql中对动态输入进行分类

时间:2018-03-09 05:32:09

标签: php mysql

我有两种类型的输入字段动态生成,添加更多按钮一个用于添加类别,另一个用于子类别。我必须将不同的子类别分组到一个主要类别。如何将它们插入到mysql数据库中,有人请帮助我,提前谢谢。

<html>
<body>
<button type="button" value="add more" 
onClick="addInput_a('dynamicInput_a');"></button>
<div id="dynamicInput_a">
<label>Category</label>
<input name="a_meaning[]">                        
</div>
<button type="button" value="add more"  onClick="addInput_b('dynamicInput_b');"></button>
<div id="dynamicInput_b">
<label>Sub Category</label>
<input name="b_meaning[]">                        
</div>

<script>
var counter = 1;
var limit = 25;
function addInput_a(divName){
 if (counter == limit)  {
      alert("You have reached the limit of adding " + counter + " inputs");
 }
 else {
      var newdiv = document.createElement('div');
      newdiv.innerHTML = " <br> <label>Category</label><input 
name='a_meaning[]'>";
      document.getElementById(divName).appendChild(newdiv);
      counter++;
 }
}
</script>
       <script>
var counter = 1;
var limit = 25;
function addInput_b(divName){
 if (counter == limit)  {
      alert("You have reached the limit of adding " + counter + " inputs");
 }
 else {
      var newdiv = document.createElement('div');
      newdiv.innerHTML = " <br> <label>Sub Category</label><input 
name='b_meaning[]'>";
      document.getElementById(divName).appendChild(newdiv);
      counter++;
 }
}
</script>
    </body>
 </html>

0 个答案:

没有答案