我正在使用 jquery-ui 滑块创建从强烈不同意到强烈同意的连续比例(示例 - http://enscholar.com/slider/)。我创建了一个对象来保存我想要显示的不同字符串值,但我想将数值存储到数据库中 - 而不是字符串。
这是我到目前为止所拥有的:
var p = {
0: "Strongly Disagree",
5: "Strongly Disagree",
10: "Strongly Disagree",
15: "Strongly Disagree",
20: "Strongly Disagree",
25: "Disagree",
30: "Disagree",
35: "Disagree",
40: "Disagree",
45: "Neutral",
50: "Neutral",
55: "Neutral",
60: "Neutral",
65: "Agree",
70: "Agree",
75: "Agree",
80: "Agree",
85: "Strongly Agree",
90: "Strongly Agree",
95: "Strongly Agree",
100: "Strongly Agree"
};
$( ".slider" ).slider({
animate:true,
range: "min",
value:50,
min: 0,
max: 100,
step: 5,
slide: function( event, ui ) {
$( "#slider-result" ).val(p[ui.value]);
}
});
$("#slider-result").val(p[$(".slider").slider("value")]);
$( ".slider-2" ).slider({
animate:true,
range: "min",
value:50,
min: 0,
max: 100,
step: 5,
slide: function( event, ui ) {
$( "#slider-result-2" ).val(p[ui.value]);
}
});
$("#slider-result-2").val(p[$(".slider-2").slider("value")]);
});
从那里我只是收集输入中的值 - 我觉得这是问题所在,但我不知道从哪里开始。
<input type="text" id="slider-result" name="career" readonly/>
关于如何向用户显示字符串但将数值存储到数据库的任何想法?
很感谢任何形式的帮助!!