简体   繁体   English

如何设置变量或存储下拉列表中的选定项目

[英]how to set a variable or store selected item from drop down list

I am making a registration form which has some drop down selection options (made with bootstrap) how do I store which option was selected from my drop down and make use of that value?我正在制作一个注册表单,其中包含一些下拉选择选项(使用引导程序制作)我如何存储从我的下拉列表中选择的选项并使用该值? I want to select an option and have it stored so I can make use of it to store information in a database.我想 select 一个选项并将其存储,以便我可以利用它在数据库中存储信息。

<select onchange="console.log(this.value)">
  <option value="A">A</option>
  <option value="B">B</option>
</select>

Whenever the option changes, this.value gets changed. Whenever the option changes, this.value gets changed. this is nothing but a reference of the select component. this不过是 select 组件的参考。 You can use this to call your own function to fire HttpRequest.您可以使用它来调用您自己的 function 来触发 HttpRequest。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM