0
jqueryでクッキーを使用している新規ユーザーと元ユーザーのためのウェルカムページを作成しようとしています。ただし、各ユーザーの新しいデータを使用してフォームを送信すると、「ようこそ新規ユーザー」は表示されません。あたかも彼が既にサイト上にフォームを提出しているかのようにユーザーを歓迎します。上記で新しいユーザーを歓迎するか、jquery Cookieを使用して繰り返しユーザーを歓迎する方法は?
customername = $.cookie('fullname', fname + " " + lname, {expires: 365});
if(customername == null) {}
:
<h1 class="center">
<span id="wel"></span>
</h1>
<form id="form" autocomplete="on">
<br>
<input type="text" name="firstname" id="firstname" placeholder="Enter the first name" pattern="[A-Za-z\-]+" maxlength="25">
<br>Last Name:
<br>
<input type="text" name="lastname" id="lastname" placeholder="Enter the last name" pattern="[A-Za-z\-]+" maxlength="25">
<input type="submit" id="submit" value="Place Order!" />
</form>
var customername = []; // outside the function
var fname = $("#firstname").val();
var lname = $("#lastname").val();
customername = $.cookie('fullname', fname + " " + lname, {expires: 365});
if(customername == null) {
$("#wel").html("Welcome New Customer");
} else {
$("#wel").html("Welcome " + $.cookie("fullname"));
}
コードの 'var customername'ブロックを持つものも関数の外にあるべきですか? –
技術的には、コード内には「機能」は全くありません。 'そのまま'の上にコードを投稿する必要があります。上部のセクションが下部セクションの真上にあり、結合されたコードを必ず '