情報処理実習3B(Web)

2017年度 前期 木04 15:15-16:45 瀬田2-119

課題

07.IO/color.php

表示
ソース

<?php
$backgrounds = array(
'白' => 'white','ラベンダー' => 'lavender','薄桜'=>'#fdeff2','スカイブルー'=>'#a0d8ef','アスパラガスグリーン'=>'#dbebc4','ライムライト'=>'#fff799'
);
$colors = array(
'黒' => 'black','クリムソン' =>'crimson','ミッドナイトブルー'=>'midnightblue','ダークグリーン'=>'darkgreen','ダークオレンジ'=>'darkorange'
);

$background = htmlspecialchars($_GET['background'], ENT_QUOTES);
$color = htmlspecialchars($_GET['color'], ENT_QUOTES);
?>
<!DOCTYPE html>
<html lang="ja">
<head>
   <meta charset="UTF-8" />
   <meta name="viewport" content="initial-scale=1.0">
   <title>表示設定変更</title>
   <style>
/*ここでスタイルを決める☆*/
body{
    background:<?php print '';?>;
    color:<?php print '';?>;
}   
   </style>
</head>
<body>
<h1>表示設定変更</h1>
<form action="" method="get">
<div style="display:-webkit-flex;display:flex;-webkit-flex-direction:row;flex-direction:row">
<fieldset>
<legend>背景色</legend>
<select name="background" size="<?php print count($backgrounds);?>">
<?php
foreach($backgrounds as $label => $value){
    print "<option value=\"{$value}\""; if($value == $_GET['background']) print ' selected'; print">{$label}</option>";
}
?>
</select>
</fieldset>
<fieldset>
<legend>文字色</legend>
<select name="color" size="<?php print count($colors);?>">
<?php
foreach($colors as $label => $value){
    print "<option value=\"{$value}\""; if($value == $_GET['color']) print ' selected'; print">{$label}</option>";
}
?>
</select>
</fieldset>
</div>
<button type="submit" name="choice">決定</button>
</form>
</body>
</html>