月: 2012年12月

javascriptでinputの内容によってactionURLを変更する

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>

Ubuntuでapache2のrewrite を有効にする

Ubuntuでapache2のrewriteを有効にする作業をしたのでメモ。

# a2enmod rewrite
Enabling module rewrite.
To activate the new configuration, you need to run:
# service apache2 restart

# vi sites-available/default
※rewrite の設定内容は割愛します。

# service apache2 restart
* Restarting web server apache2

 apache2: Could not reliably determine the server's fully qualified domain name, using 127.0.1.1 for ServerName
... waiting apache2: Could not reliably determine the server's fully qualified domain name, using 127.0.1.1 for ServerName

© 2023 Opendream

Theme by Anders Noren上へ ↑