0
<html>
<head>
</head>
<body>
<script>
function isVisible(){
if(document.getElementById("nt").checked==true){
document.getElementById("opt").style.visibility="hidden";
}
else{
document.getElementById("opt").style.visibility="visible";
}
}
</script>
<form align="center" method="post">
<input type="radio" name="teaching" id="t" value="teaching" onchange="isVisible()"> Teaching<br>
<input type="radio" name="teaching" id="nt" value="non-teaching" onchange="isVisible()"> Non-teaching<br>
Post Code <input type="text" name="pcode" id="pcode"><br>
Post Name <input type="text" name="pname" id="pname"><br>
<div id="opt">
Department <input type="text" name="dept" id="dept">
</div>
<input type="button" name="addv" id="addv" value="Add Vacancy" onclick="javascript: form.action='hello.php';">
</form>
</body>
</html>
上記はaddvacancy.phpです。 Add Vacancyボタンをクリックすると、hello.phpに誘導されていません。それは保持されているテキストボックスの値とともに同じページに残ります。以下はhello.phpのコードです。ボタンを押したときにページがリダイレクトされない
hello.php
<html>
<head>
</head>
<body>
<?php
echo "Hello!";
?>
</body>
</html>
ご返信ありがとうございます。私は入力タグからonclick属性を削除し、図のように
'input'の型を* button *から* submit *に変更しましたか?したがって、次のようになります。 ' Marcus
いいえ、私はしませんでした。どうもありがとう。今働いている。 :) – Nancy