いくつかのフィールドを持つWebページを作成しています。エラーが発生するため、すべてのフィールドに入力しない限り、phpコードを実行したくありません。
これが私のhtmlコードです:
<html>
<body bgcolor="AliceBlue">
<form action="WorkingVersionV2.php" method="post">
<p>Which database do you wish to access? <center> <input type="text" name="database"/> </center></p>
<p>What table would you like to examine? <center><input type="text" name="oldtablename"/></center></p>
<p>What would you like to name the table produced? <center><input type="text" name="newtablename"/></center></p>
<p>Start at row: <center><input type="text" name="startrow"/></center></p>
<p>Number of rows to search through:<center> <input type="text" name="numberrows"/> </center></p>
<center><input type = "submit" onclick="checkFields()"/></center>
</form>
<script type="text/javascript">
function checkFields()
{
var x = document.getElementById("database").innerHTML;
if(x=="")
{
alert("You forgot to enter a database name");
}
}
</script>
</body>
</html>
フィールドに入力しないと、ポップアップボックスを投げるとユーザーが停止するだろうと思いました。ただし、ユーザーが[送信]をクリックしても、ポップアップボックスは表示されないため、閉じた後もphpコードが実行されるかどうかはわかりません。
HTML / javascriptは私の得意ではありません。これを行うためのより良い、またはより簡単な方法がある場合は、私に知らせてください。