Python社区  »  DATABASE

如何使用JavaScript将html select中的值保存到MySQL数据库

T.K. Tamil Arasi • 1 周前 • 18 次点击  

我想添加onclick函数到html选择的add和remove按钮,使用JavaScript将值保存到数据库中。我怎么能做到?

function getDesc() {

  var req = new XMLHttpRequest();
  req.addEventListener("load", loadDesc);
  req.open("GET", "/getevent", true);
  req.send();
}


function loadDesc(selector) {


  var getevent = JSON.parse(this.responseText);
  selector = document.getElementById("selector_description");

  for (var i = 0; i < getevent.event.rows.length; i++) {

    var opt = document.createElement("option");
    opt.value = getevent.event.rows[i].id;
    opt.text = getevent.event.rows[i].id + '' + ':' + '' +
      getevent.event.rows[i].description;
    selector.appendChild(opt);



  }
}
<div class="selector-box">
  <select id="selector_description" autofocus><button id="add">Add</button>

  </select>
  <button onclick="Add()">Add</button>
  <button onclick="Remove()">Remove</button>
</div>
Python社区是高质量的Python/Django开发社区
本文地址:http://www.python88.com/topic/54637
 
18 次点击  
分享到微博