首页 > 解决方案 > 勾选带有 nodejs 发布请求的单选按钮

问题描述

我正在尝试使用单选按钮进行发布请求。HTML 页面是一个有 2 个单选按钮的表单:

<form name="create" class="jqTransform FormValidate" id="MyForm" action="/My/Form/1" method="post">
<p class="a"><input type="radio" class="radio" value="1" name="choices" id="18" /><label for="r1">Radio button r1</label></p>
<p class="a"><input type="radio" class="radio" value="2" name="choices" id="r2" /><label for="r2">Radio button R2</label></p>
<input type="submit" class="Bbutton" title="Click here to go to next step" value="next step" name="nextStep" />

我想在这样的帖子请求中选择 R1 或 R2:

request({
        url: url,
        method: 'post',
        form: {
             //Here maybe ? something to add for checking a radio button?
            nextStep: 'next step',
        },
        headers: {
            'User-Agent': 'MyUserAgent',
            'Referer': 'https://myurl/My/Form/1'
        },
        jar: jar
    }, function(err, response, body) {do something after}

我知道可以勾选一个复选框

condition: 'on'

在请求表单参数里面。但我不知道如何继续检查单选按钮。

任何帮助表示赞赏!谢谢你。

标签: node.js

解决方案


对不起,我是 nodejs 的菜鸟。

回答 :

choices : 1

表格内。


推荐阅读