0

我在这段代码中有一个条件问题。除了该行之外,该代码工作正常。

<if condition="$show['member']">
<script type="text/javascript" >
$(function() {
$("#submitbutton$post[postid]").click(function() {
var username = $("#username_$post[postid]").val();
var reputationamount = $("#amount_$post[postid]").val();
var dataString = 'username='+ username + '&reputationamount=' + reputationamount;

if(username == '' || reputationamount == '') {

$('.errorsameuser_$post[postid]').hide();
$('.errorreputation_$post[postid]').hide();
$('.errorempty_$post[postid]').fadeIn(200);


} else if (username == '$bbuserinfo[username]') {

$('.errorempty_$post[postid]').hide();
$('.errorreputation_$post[postid]').hide();
$('.errorsameuser_$post[postid]').fadeIn(200);

} else if (reputationamount >= '$bbuserinfo[reputation]' || reputationamount <= '0') {

$('.errorempty_$post[postid]').hide();
$('.errorsameuser_$post[postid]').hide();
$('.errorreputation_$post[postid]').fadeIn(200);

} else {
$.ajax({
type: "POST",
url: "donaterep.php",
data: dataString,
success: function(){
$('.errorempty_$post[postid]').hide();
$('.errorsameuser_$post[postid]').hide();
$('.errorreputation_$post[postid]').hide();
$('#donaterepbox_$post[postid]').fadeOut();
$('.success_$post[postid]').fadeIn(500);
}
});
} 
return false;
});
});
</script>

这部分不起作用:

否则 if (reputationamount > '$bbuserinfo[reputation]' || 声誉量 <= '0') {

$('.errorempty_$post[postid]').hide();
$('.errorsameuser_$post[postid]').hide();
$('.errorreputation_$post[postid]').fadeIn(200);

}

信誉量 = 用户输入的内容。(示例:5) $bbuserinfo[reputation] = 捐赠人的代表点数。(例:4)

所以让我们说它是..

如果(5 > 4 || 5 <= '0'){

$('.errorreputation_$post[postid]').fadeIn(200);

}

它应该抛出该错误,而是运行 ajax 帖子。

帮助?

其他条件工作正常。

4

1 回答 1

1

这是因为 compare() 运算符的两边<都是字符串,如果运算符的一侧是数字,那么在执行比较之前,javascript 会将另一侧也转换为数字

尝试

} else if (reputationamount >= $bbuserinfo[reputation] || reputationamount <= 0) {
于 2013-06-22T03:36:24.797 回答