コメント |
http://winofsql.jp/php/basic/log_06.php
@DIV
<!DOCTYPE html>
<html lang="ja">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=600,initial-scale=1.0">
<script src="//ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<script>
$(function(){
// コンボボックスの選択されたテキストをテキストエリアにセットする
$("#set_text").click(function(){
$("#text").val( $("#action_file option:selected").text() );
});
});
</script>
</head>
<body>
<!-- ここにコンテンツを作成する -->
<form method="POST"
id="my_form"
action="log_06a.php">
<select name="php_file"
id="action_file">
<option value="log_02b.php"
<?= $_GET["php_file"] == "log_02a.php" ? "selected" : "" ?> >連結演算子で文字列の連結
</option>
<option value="log_02b.php"
<?= $_GET["php_file"] == "log_02b.php" ? "selected" : "" ?> >文字列内に変数を埋め込んで連結
</option>
</select>
<br>件名
<input type="text"
name="subject"
id="subject">
<input type="button"
id="set_text"
value="コンボボックスのテキストをセット">
<br>
<span style='vertical-align:top'>内容</span>
<textarea name="text"
id="text"
style="width:400px;height:100px;"></textarea>
<br>
<input type="submit"
name="send"
value="送信">
</form>
</body>
</html>
@END
[[log_06a.php]]
@DIV
<?php
header( "Content-Type: text/html; Charset=utf-8" );
print "<pre>";
print_r($_GET);
print_r($_POST);
print "</pre>";
print "【連結演算子で文字列の連結】<hr>";
print $_POST["subject"] . $_POST["text"];
print "<hr>";
?>
<a href="log_06.php?php_file=<?= $_POST["php_file"] ?>">戻る</a>
@END |