根据我的xhtml中作为OPML节点的流程图,我希望动态地(使用jquery,而不刷新页面)一个接一个地获取问题,这取决于前面回答的是/否,直到到达OPML中的最后消息为止。例如;
问:你有宠物吗?A:是的 问:它大吗? A:是的 问:它是狗吗? A:是的 最后:请注意,狗是不允许在这个活动!
该机制类似于提出的在这个问题上机制。然而,它需要对每个问题和回答进行编码。我正在寻找一种编写代码的方法,您可以在其中输入任何OPML,它将自动创建该行为。
在关闭javascript时,将编辑作为可读的回退,并且为了避免解析外部OPML,最好使用XOXO --大纲缩微格式而不是OPML。
发布于 2012-04-13 13:44:28
你可以这样做:http://jsfiddle.net/kayen/fGrT2/
HTML:
<div id="petTest">
<fieldset>
<legend>Do you have a pet?</legend>
<ul>
<li><label for=""><input type="radio" name="petstatus" value="Yes" /> Yes</label></li>
<li><label for=""><input type="radio" name="petstatus" value="No" /> No</label></li>
</ul>
</fieldset>
<fieldset>
<legend>Is it big?</legend>
<ul>
<li><label for=""><input type="radio" name="petsize" value="Yes" /> Yes</label></li>
<li><label for=""><input type="radio" name="petsize" value="No" /> No</label></li>
</ul>
</fieldset>
<fieldset>
<legend>Is it a dog?</legend>
<ul>
<li><label for=""><input type="radio" name="pettype" value="Yes" /> Yes</label></li>
<li><label for=""><input type="radio" name="pettype" value="No" /> No</label></li>
</ul>
</fieldset>
<fieldset>
<legend>Please note that dogs are not allowed at this event!</legend>
</fieldset>
</div>JQuery:
$("#petTest fieldset")
.hide()
.eq(0).show()
.end()
.find("input[value='Yes']")
.click(function() {
$(this).parents("fieldset").next().show(300);
})
.end()
.find("input[value='No']")
.click(function() {
$(this).parents("fieldset").nextAll().hide(300, function(){
$(this).find("input").attr("checked", false);
});
});https://stackoverflow.com/questions/7540149
复制相似问题