如何从表单提交上的单选按钮获取值
我有两个单选按钮:
<input dojoAttachPoint="sensorSwipe" id="sensorSwipe" type="radio"
dojoType="dijit.form.RadioButton" name="Sensor" checked />
<input dojoAttachPoint="sensorContinuous" id="sensorContinuous" type="radio"
dojoType="dijit.form.RadioButton" name="Sensor" />
...我正在使用 dojo xhrpost 调用以表单形式提交:
dojo.xhrPost({
url: baseUrl + path,
form: form,
timeout: 60000,
load: function(result) { PostSuccess(result, path, callbackFunction); },
error: function(error, args) { AjaxError(error, args, path, request, callbackFunction); }
});
问题是,在提交表单时,它会发送值为“on”的“Sensor”属性,无论哪个两个单选按钮中的一个被选中。我如何知道选择了哪个单选按钮?
I have two radio buttons:
<input dojoAttachPoint="sensorSwipe" id="sensorSwipe" type="radio"
dojoType="dijit.form.RadioButton" name="Sensor" checked />
<input dojoAttachPoint="sensorContinuous" id="sensorContinuous" type="radio"
dojoType="dijit.form.RadioButton" name="Sensor" />
...that I'm submitting in a form using an dojo xhrpost call:
dojo.xhrPost({
url: baseUrl + path,
form: form,
timeout: 60000,
load: function(result) { PostSuccess(result, path, callbackFunction); },
error: function(error, args) { AjaxError(error, args, path, request, callbackFunction); }
});
The issue is that when submitting the form, it sends a "Sensor" property with a value of "on", regardless of which of the two radio buttons is selected. How can I tell which radio button was selected?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您应该将
value
属性添加到来指定值。
You should add
value
attribute to the<input>
to specify the value.