我的jQuery按钮滑块工作正常,我得到它here。
但我需要的只是一个滑块,最后有两个选项,“YES”和“NO”。当滑块向左移动时,答案为是,滑块将在中间返回,反之亦然。有人知道怎么做吗?
这是我的代码:
<?php
foreach($data as $dta){
$uuid = $dta->uuid;
$categ_uuid = $dta->category_uuid;
$subcateg_uuid = $dta->subcategory_uuid;
$question = $dta->content;
}
?>
<div class="row-fluid">
<div class="span12 spacer"></div>
<!-- QUESTION or IMAGE CONTAINER -->
<div class="span12" style="margin:0;">
<div class="span1"></div>
<div class="span10">
<div class="span12">
<div class="span2"></div>
<div class="span8" id="container">
<!--<img class="media-object" data-src="holder.js/100%x230/sky/text:">-->
<?php echo $question; ?>
</div>
<div class="span2"></div>
</div>
</div>
<div class="span1" style="margin:0;"></div>
</div>
<!-- YES NO TOGGLE -->
<div class="span12" style="margin:0;">
<div class="span1"></div>
<div class="span10">
<div class="span12">
<div class="span1"></div>
<div class="span10">
<form action="<?php echo $this->config->item('8L_URL').'/system/dovote'; ?>" id="yesno-form" method="post">
<input type="hidden" name="question_uuid" value="<?php echo $uuid; ?>">
<input type="hidden" name="category_uuid" value="<?php echo $categ_uuid; ?>">
<input type="hidden" name="subcategory_uuid" value="<?php echo $subcateg_uuid; ?>">
<input type="hidden" name="answer" id="answer">
<div style="padding:30px 0px 50px 0px;">
<div id="yes" name="answer">Yes</div>
<div style="float:right;">
<div id="no" name="answer">No</div>
</div>
</div>
</form>
</div>
<div class="span1"></div>
</div>
</div>
<div class="span1" style="margin:0;"></div>
</div>
</div>
<div id="dummy_div"></div>
<div id="module-modal" class="modal hide fade" tabindex="-1"></div>
<div id="app_loader_bar"> </div>
<script type='text/javascript'>
$('#no').sliderbutton({
text: 'NO',
activate: submitForm
});
$('#yes').sliderbutton({
direction: 'left',
text: 'YES',
activate: submitForm
});
function submitForm(){
$("#answer").val($(this).attr("id"));
$('#yesno-form').submit();
};
</script>
答案 0 :(得分:0)
我有解决方案。感谢bootstrap滑块。另外我只是在CSS中做了一些事情,使它看起来两边都是“YES”和“NO”。