inputに入力された内容によってactionのURLを変更する必要があり、調べた結果次のようにするとうまく動きました。
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<script type="text/javascript">
<!--
function check() {
//alert(document.ansform.ans.value);
if (document.ansform.ans.value == "テキストの内容") {
document.ansform.action="http://google.co.jp/";
document.ansform.submit(); // ←なくても動作した
}
else
{
document.ansform.action="http://yahoo.co.jp/";
document.ansform.submit(); // ←なくても動作した
}
}
-->
</script>
</head>
<body>
<form name="ansform" method="get" onsubmit="check()">
<input name="ans" type="text" value="" />
<input type="submit" value="送信" />
</form>
</body>
</html>
最近のコメント