我正在使用PHP MySql。
如何在单个文本框中显示下一个和上一个日期。
场景是-我将在某个日期使用mysql获取一些数据(字符串)。我想在各个日期显示各个数据。
2014年9月6日-'早安'
2014年6月6日-'晚安'。
<input type="button" value="prev">
<input type="text">
<input type="button" value="next">
<span class="date_data"></span> //To display data
假设-我有6月8日的“早安”字串。还有6月20日的“晚安”字样。因此,当我选择8th时,按prev键将显示“ Good Morning”。同样,当我进入第20位时。它应该显示“晚安”
假设您的json数据具有类似这样的格式,
var date = [{
"Date": "09/06/2014",
"Message": "Good Morning"
},
{
"Date": "10/06/2014",
"Message": "Good Night"
}, {
"Date": "11/06/2014",
"Message": "Good Evening"
}
];
var index = 0;
$("#prev").click(function () {
$("#txt").val(date[index].Date);
$("#msg").html(date[index].Message);
index--;
});
$("#next").click(function () {
$("#txt").val(date[index].Date);
$("#msg").html(date[index].Message);
index++;
});
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句