私はJquery/クライアント側のスクリプトに非常に慣れていないということから始めたいと思います。上司が顧客にフォームの送信を確認するための何らかの方法を望んでいたとき、私はちょっと盲目的でした。
これは私のjquery/ヘッダーです:
<head>
<title>Access Point</title>
<meta http-equiv="Content-Type" content="text/html"; charset="utf-8" />
<link rel="stylesheet" href="<?php echo base_url();?>css/mainstyle.css" type="text/css" />
<link rel="stylesheet" href="<?php echo base_url();?>css/secondarystyles.css" type="text/css"/>
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>
<script>
$("#signinform").submit( function(e)
{
if (!confirm("If you click OK you will be inserted into student queue. Please take a seat and wait."))
{
e.preventDefault();
return;
}
});
</script>
</head>
そしてこれは私のフォームです:
<?php echo form_open('staff_controller/agree', 'id="signinform"') ?>
<input type="checkbox" id="agree" name="options" value="agree"<?php echo form_checkbox('options','agree') ?>I have read and understood the above <br /> <font color="#ff0000" size="3">(Please click on the box)</font></input>
<br />
<br />
<br />
<?php
echo form_submit('submit', 'Submit');
echo anchor('staff_controller/studentlogin', 'Cancel');
echo form_close();
?>
私のphpスクリプトは、チェックボックスがチェックされているかどうかをチェックし(要件に同意するため)、送信がクリックされているかどうかもチェックします。クリックされた場合は、値をデータベースに送信します。私の理解では、このスタイルを引き続き使用してデータを処理できます。ユーザーが送信していることをユーザーが認識できるように、jqueryを中央に配置するだけです。私はこのコードをインターネットで見つけましたが、これをデバッグする方法がわかりません。また、フォームの送信を「キャンセル」するかどうかを確認するために、jqueryで確認する予定です。
編集1:
ソースコードを見ると、それは「機能するはず」です:
form action = "https://www.finaidtest.com/index.php/staff_controller/agree" id = "signinform" method = "post" accept-charset = "utf-8"
そして私の更新された確認:
<script src="//ajax.googleapis.com/ajax/libs/jqueryui/1.10.1/jquery-ui.min.js"></script>
<script>
$(document).on('submit', "#signinform", function(e)
{
if (!confirm("If you click OK you will be inserted into student queue. Please take a seat and wait"))
{
e.preventDefault();
return;
}
});
</script>
編集2
ムーサのおかげで、今はすべてうまくいきます!ありがとう!!
コード:
<script src="<?php echo base_url();?>javascript/js/jquery.js" type="text/javascript"></script>
<script>
$(document).on('submit', "#signinform", function(e)
{
if (!confirm("If you click OK you will be inserted into student queue. Please take a seat and wait"))
{
e.preventDefault();
return;
}
});
</script>