如何从有两个文本框的jQuery对话框中获取值?我可以将它们存储在JavaScript变量中吗
How can I get values from jQuery dialog box which has 2 text boxes? Can I store them in a JavaScript variable?
我尝试过jQuery,但无法从该对话框中获取值。有没有任何方法可以将这些值存储在JavaScript变量中(即,来自jQuery对话框)。
<div id="dialog-message2">
<center><p>
What percentage would you like to refund?</br>
<input type="text" id="per" name="per" > %
</p></center>
<center><p>
Reason: <input type="text" id="reason" name="reason" >
</p></center>
<br><center><input type="submit" id="proceed" name="proceed" value="PROCEED" style='width:60px;height:30px;background-color:#0066CC;color:#FFFAF0; -webkit-border-radius: 9px'></center>
</div>
或者JavaScript中还有其他方法吗?
$(document).ready(function(){
$("#proceed").click(function(){
//using JQuery
var perValue = $("#per").val();
var reasonValue = $("#reason").val();
console.log(reasonValue);
console.log(perValue);
});
});
//using javascript
document.getElementById('proceed').onclick = Onclick;
function Onclick(){
var reasonValue = document.getElementById("reason").value;
var perValue = document.getElementById("per").value;
console.log(reasonValue);
console.log(perValue);
}
我已经包含了Jquery和基于按钮的onlick函数的普通javascript。你可以在JsFiddle上测试一下。您可以检查控制台以查看var值的输出。
这就是您想要的吗?
var something = document.getElementById("yourIDhere").value;
相关文章:
- 我可以'当用户更改页面时,我无法在Iframe中获取聊天内容
- 我可以't从通过Ajax创建的select元素中设置值或获取值
- 我可以从类型编号中获取字符串值吗?
- 如何创建一个组件,我可以设置在 Angular 2 中的属性中获取 URL 数据
- 我可以替换“;获取“;方法用“;POST”;代码库中的任何位置
- 我可以't从draft js中获取html输出
- 我可以使用ajax按钮获取下拉值并填写表单吗
- 我可以在浏览器地址栏上获取#值吗
- 我可以't获取单选按钮上的onclick属性以执行javascript函数
- 我可以在不使用XMLHttpRequest或文档对象的情况下使用Javascript来获取网页吗
- 我可以在谷歌地图上使用OpenStreetMap数据创建获取路线吗?如何
- 添加事件处理程序以获取按钮单击LeadPage,我可以在其中对正文进行编码
- 我可以通过Javascript从另一个网页获取特定的页面HTML代码吗?
- 我如何在我的 AngularJS 中获取这个 D3.js HTML 元素,以便我可以操作它
- 我可以使用Jquery获取元素的HTML源代码吗?
- 如何获取不同选项卡的实例,以便我可以存储变量/执行特定于各个选项卡的操作
- 我可以在没有对象函数调用的情况下获取(可能是计算的)属性值吗?
- 在下划线js,我可以在输入后使用弹拨方法获取多列,其中方法作为linq选择投影
- 当存在嵌套的jQuery调用时,我可以获取event.target吗
- 为什么我可以获取console.log(变量)来给出我的值,而不能返回变量