我需要帮助...我想自动单击一个单选按钮...但还需要检查句子(标签)...例如...() <-radio button
<label>How much is 1+1?</label><br/>
<input type="radio" name="group1" value="2"/>()2<br/>
<input type="radio" name="group1" value="3"/>()3<br/>
<input type="radio" name="group1" value="4"/>()4
我尝试使用这个脚本:
// ==UserScript==
// @name script
// @description Auto select rpt radio button
// @include *
// ==/UserScript==
if(radio=document.evaluate('//input[@type="radio" and @value="2"]',document,null,9,null).singleNodeValue)
radio.checked=true;
好的,这段代码..click answer ()2 但是如果我有以下情况会发生什么:
<label>How much is 1+1?</label><br/>
<input type="radio" name="group1" value="2"/>()2<br/>
<input type="radio" name="group1" value="3"/>()3<br/>
<input type="radio" name="group1" value="4"/>()4
How much is 4+2?<br/>
<input type="radio" name="group1" value="8"/>()8<br/>
<input type="radio" name="group1" value="2"/>()2<br/>
<input type="radio" name="group1" value="6"/>()6
什么都没有发生,因为有两个值叫“2”..所以我尝试修改代码先检查句子然后标记答案(但我没有很好地掌握它)...
if(label=document.evaluate('//label[@value="How much is 1+1?"]',document,null,9,null).singleNodeValue)&&(radio=document.evaluate('//input[@type="radio" and @value="2"]',document,null,9,null).singleNodeValue)
radio.checked=true;
我的意图是添加第二个条件,检查带有“1+1 是多少?”的值的标签。
谁能指导我如何做到这一点?
编辑:示例链接: Google docs form
页面代码如下所示: 标签:
<label class="ss-q-title" for="entry_0">How much is 1+1
<span class="ss-required-asterisk">*</span></label>
收音机:
<ul class="ss-choices"><li class="ss-choice-item"><label class="ss-choice-label"><input name="entry.0.group" value="2" class="ss-q-radio" id="group_0_1" type="radio">
2</label></li> <li class="ss-choice-item"><label class="ss-choice-label"><input name="entry.0.group" value="3" class="ss-q-radio" id="group_0_2" type="radio">
3</label></li> <li class="ss-choice-item"><label class="ss-choice-label"><input name="entry.0.group" value="4" class="ss-q-radio" id="group_0_3" type="radio">
4</label></li>
</ul>