Notice: Undefined index: wjs_cookie

w执行顺序。

ok

 1 <!doctype html>
 2 <html>
 3 <head>
 4     <meta charset="UTF-8">
 5 </head>
 6 
 7 <body>
 8 
 9 <form action="" method="post" id="amz_reviews" style="display: inline;">
10     <button type="submit" name="type"
11             value="amz_reviews" <?php if (!isset($_COOKIE['wjs_cookie']) || (isset($_COOKIE['wjs_cookie']) && $_COOKIE['wjs_cookie'] == 'amz_reviews')) echo 'style=" background-color:red;" '; ?>
12             onclick="w('amz_reviews')">差评
13     </button>
14 </form>
15 
16 <form action="" method="post" id="amz_similar_sellers" style="display: inline;">
17     <button type="submit"
18             name="type"   <?php if (isset($_COOKIE['wjs_cookie']) && $_COOKIE['wjs_cookie'] == 'amz_similar_sellers') echo 'style=" background-color:red;" '; ?>
19             value="amz_similar_sellers"
20             onclick="w('amz_similar_sellers')">跟卖
21     </button>
22 </form>
23 
24 <form action="" method="post" id="amz_listing" style="display: inline;">
25     <button type="submit"
26             name="type"  <?php if (isset($_COOKIE['wjs_cookie']) && $_COOKIE['wjs_cookie'] == 'amz_listing') echo 'style=" background-color:red;" '; ?>
27             value="amz_listing"
28             onclick="w('amz_listing')">评分、类目变化
29     </button>
30 </form>
31 </body>
32 </html>
33 <script>
34     document.cookie = 'wjs_cookie=' + 'amz_reviews';
35 
36     function w(id) {
37         document.cookie = 'wjs_cookie=' + id;
38         document.getElementById(id).submit();
39     }
40 
41     console.log(document.cookie);
42 </script>

 ok

 1 <script>
 2     document.cookie = 'wjs_cookie=' + 'amz_reviews';
 3 
 4     function w(id) {
 5         document.cookie = 'wjs_cookie=' + id;
 6         document.getElementById(id).submit();
 7     }
 8 
 9     console.log(document.cookie);
10 </script>
11 <!doctype html>
12 <html>
13 <head>
14     <meta charset="UTF-8">
15 </head>
16 
17 <body>
18 
19 <form action="" method="post" id="amz_reviews" style="display: inline;">
20     <button type="submit" name="type"
21             value="amz_reviews" <?php if (!isset($_COOKIE['wjs_cookie']) || (isset($_COOKIE['wjs_cookie']) && $_COOKIE['wjs_cookie'] == 'amz_reviews')) echo 'style=" background-color:red;" '; ?>
22             onclick="w('amz_reviews')">差评
23     </button>
24 </form>
25 
26 <form action="" method="post" id="amz_similar_sellers" style="display: inline;">
27     <button type="submit"
28             name="type"   <?php if (isset($_COOKIE['wjs_cookie']) && $_COOKIE['wjs_cookie'] == 'amz_similar_sellers') echo 'style=" background-color:red;" '; ?>
29             value="amz_similar_sellers"
30             onclick="w('amz_similar_sellers')">跟卖
31     </button>
32 </form>
33 
34 <form action="" method="post" id="amz_listing" style="display: inline;">
35     <button type="submit"
36             name="type"  <?php if (isset($_COOKIE['wjs_cookie']) && $_COOKIE['wjs_cookie'] == 'amz_listing') echo 'style=" background-color:red;" '; ?>
37             value="amz_listing"
38             onclick="w('amz_listing')">评分、类目变化
39     </button>
40 </form>
41 </body>
42 </html>

Notice:  Undefined index: wjs_cookie

 1 <script>
 2     document.cookie = 'wjs_cookie=' + 'amz_reviews';
 3 
 4     function w(id) {
 5         document.cookie = 'wjs_cookie=' + id;
 6         document.getElementById(id).submit();
 7     }
 8 
 9     console.log(document.cookie);
10 </script>
11 <!doctype html>
12 <html>
13 <head>
14     <meta charset="UTF-8">
15 </head>
16 
17 <body>
18 
19 <form action="" method="post" id="amz_reviews" style="display: inline;">
20     <button type="submit" name="type"
21             value="amz_reviews" <?php if ($_COOKIE['wjs_cookie'] == 'amz_reviews') echo 'style=" background-color:red;" '; ?>
22             onclick="w('amz_reviews')">差评
23     </button>
24 </form>
25 
26 <form action="" method="post" id="amz_similar_sellers" style="display: inline;">
27     <button type="submit"
28             name="type"   <?php if ($_COOKIE['wjs_cookie'] == 'amz_similar_sellers') echo 'style=" background-color:red;" '; ?>
29             value="amz_similar_sellers"
30             onclick="w('amz_similar_sellers')">跟卖
31     </button>
32 </form>
33 
34 <form action="" method="post" id="amz_listing" style="display: inline;">
35     <button type="submit"
36             name="type"  <?php if ($_COOKIE['wjs_cookie'] == 'amz_listing') echo 'style=" background-color:red;" '; ?>
37             value="amz_listing"
38             onclick="w('amz_listing')">评分、类目变化
39     </button>
40 </form>
41 </body>
42 </html>

Notice:  Undefined index: wjs_cookie

 1 <!doctype html>
 2 <html>
 3 <head>
 4     <meta charset="UTF-8">
 5 </head>
 6 <script>
 7     document.cookie = 'wjs_cookie=' + 'amz_reviews';
 8 
 9     function w(id) {
10         document.cookie = 'wjs_cookie=' + id;
11         document.getElementById(id).submit();
12     }
13 
14     console.log(document.cookie);
15 </script>
16 <body>
17 
18 <form action="" method="post" id="amz_reviews" style="display: inline;">
19     <button type="submit" name="type"
20             value="amz_reviews" <?php if ($_COOKIE['wjs_cookie'] == 'amz_reviews') echo 'style=" background-color:red;" '; ?>
21             onclick="w('amz_reviews')">差评
22     </button>
23 </form>
24 
25 <form action="" method="post" id="amz_similar_sellers" style="display: inline;">
26     <button type="submit"
27             name="type"   <?php if ($_COOKIE['wjs_cookie'] == 'amz_similar_sellers') echo 'style=" background-color:red;" '; ?>
28             value="amz_similar_sellers"
29             onclick="w('amz_similar_sellers')">跟卖
30     </button>
31 </form>
32 
33 <form action="" method="post" id="amz_listing" style="display: inline;">
34     <button type="submit"
35             name="type"  <?php if ($_COOKIE['wjs_cookie'] == 'amz_listing') echo 'style=" background-color:red;" '; ?>
36             value="amz_listing"
37             onclick="w('amz_listing')">评分、类目变化
38     </button>
39 </form>
40 </body>
41 </html>

Notice:  Undefined index: wjs_cookie

 1 <!doctype html>
 2 <html>
 3 <head>
 4     <meta charset="UTF-8">
 5 </head>
 6 <body>
 7 <script>
 8     document.cookie = 'wjs_cookie=' + 'amz_reviews';
 9 
10     function w(id) {
11         document.cookie = 'wjs_cookie=' + id;
12         document.getElementById(id).submit();
13     }
14 
15     console.log(document.cookie);
16 </script>
17 <form action="" method="post" id="amz_reviews" style="display: inline;">
18     <button type="submit" name="type"
19             value="amz_reviews" <?php if ($_COOKIE['wjs_cookie'] == 'amz_reviews') echo 'style=" background-color:red;" '; ?>
20             onclick="w('amz_reviews')">差评
21     </button>
22 </form>
23 
24 <form action="" method="post" id="amz_similar_sellers" style="display: inline;">
25     <button type="submit"
26             name="type"   <?php if ($_COOKIE['wjs_cookie'] == 'amz_similar_sellers') echo 'style=" background-color:red;" '; ?>
27             value="amz_similar_sellers"
28             onclick="w('amz_similar_sellers')">跟卖
29     </button>
30 </form>
31 
32 <form action="" method="post" id="amz_listing" style="display: inline;">
33     <button type="submit"
34             name="type"  <?php if ($_COOKIE['wjs_cookie'] == 'amz_listing') echo 'style=" background-color:red;" '; ?>
35             value="amz_listing"
36             onclick="w('amz_listing')">评分、类目变化
37     </button>
38 </form>
39 </body>
40 </html>
原文地址:https://www.cnblogs.com/rsapaper/p/6349460.html