我有此代码用于创建动态数量的滑块,每个滑块具有动态数量的答案,但我无法理解我的代码的两件事:
为什么只显示一个滑块?(我的 sql 表上的第一个 id 滑块编号)
为什么金额框中只出现正确的ini值?移动滑块时出现
A r r a y
(每次移动滑块一个字符)?<script> var arrayslidersvalueanswers="<?= $tableslidersanswervalues ?>"; <?php foreach ($tableslidersqid as $qid) { ?> <?php foreach ($qid as $index) { ?> <?php echo $index;?> <?php foreach ($tableslidersanswersid as $qanswerid) { ?> <?php foreach ($qanswerid as $indexanswer) { ?> var answers="<?= $qanswerid ?>"; var qid= "<?= $index ?>"; jQuery(document).ready(function(){ /////////////////////SLIDER !!!!!!!!!!!!!!!!!!!!!!!!!!! var valor="<?= $tableslidersanswervalues[1][0] ?>"; // Ini slider $(document.getElementById("amount"+qid+"[]")).val(valor); $(document.getElementById("slider"+qid+"[]")).slider({ min: 1, max:arrayslidersvalueanswers.length, slide: function( event, ui) { var ans=answers[0][1] ; $(document.getElementById("amount"+qid+"[]")).val(answers[ui.value-1][0]); } //end slider ini method builder });//END OF FUNCTION }); });// end JavaScript document function <?php } ?> <?php } ?> <?php } ?> <?php } ?> </script> <html> <p> <label for="amount< ?= $row_Answer['QuestionIDFK'];?>">< ?php echo $row_questionset['QuestionValue']; ?>< /label> <input type="text" id="amount< ?= $row_Answer['QuestionIDFK'];?>[]" name="amount< ?= $row_Answer['QuestionIDFK'];?>[]" /> </p> <div id="slider< ?= $row_Answer['QuestionIDFK'];?>[]" name="slider< ?php echo $row_Answer['AnswerValue']; ?>[]" >< /div> </html>