-3

私の jquery/java スキルは存在しません....ちょっとした助けが必要です:

私の上司は、顧客がレビューを書き、ディスカウントの星を付けてから送信ボタンを押すフォームを作りたいと考えています。3 つ以上の星を選択すると、星の少ないレビューを送信したユーザーとは別のページに移動します。

選択した星に応じてその場でリンクを変更する j クエリ ボタンを使用することは可能ですか?

j query Star-rating プラグインを使用しています。

    <script type="text/javascript" src="../src/rating.js"></script>
    <link rel="stylesheet" href="../src/rating.css" type="text/css" media="screen" title="Rating CSS">

    <script type="text/javascript">
        $(function(){
            $('.container').rating();
        });


    </script>
</head>

<body>

<h1><a title="Full Documentation" href="http://irfandurmus.com/projects/jquery-star-rating-plugin/">jQuery Star Rating Plugin</a></h1>

    <section class="container">
        <input type="radio" name="example" class="rating" value="1" />
        <input type="radio" name="example" class="rating" value="2" />
        <input type="radio" name="example" class="rating" value="3" />
        <input type="radio" name="example" class="rating" value="4" />
        <input type="radio" name="example" class="rating" value="5" />
    </section>

<script type="text/javascript">
if  $('.container').rating(4,5) {
    echo "<a href="eventual link> Click here to receive your discount code</a>" ;
}
else $('.container').rating(1,2,3) {
    echo "<a href="eventual link>Click here to recieve your discount code</a>";
}
   </script>
4

3 に答える 3

2
$('.container').rating({
     callback: function(value){
          if(value > 3){
               $('.container').after('<a href="eventual link"> Click here to receive your discount code</a>');
          }else{
               $('.container').after('<a href="eventual link"> Click here to receive your discount code</a>');
          }
     }
});
于 2013-06-12T20:37:45.560 に答える
1

この非常によく似た質問の回答を使用して、スター評価のクリック イベントにコールバックをアタッチできます。

$('.container').rating({ 
  callback: function(value, link){ 
     if (value > 3)
        window.location.href = "http://example.org";
     else
        window.location.href = "http://stackoverflow.com";
  } 
});
于 2013-06-12T20:39:19.793 に答える
1

function を作成し、onClick()それを送信ボタン (または任意の要素) にアタッチしてから、メソッド内で次のように言うことができます。

if (stars >= 3) {
 window.location = 'http://www.mysite.com/goodratingpage'
} else
 window.location = 'http://www.mysite.com/badratingpage'
}

(window.locationご想像のとおり) は、ユーザーを別のページにリダイレクトするだけです。

于 2013-06-12T20:33:02.530 に答える