Как это исправить, чтобы когда php вызывал $ fontcolor
и пользователь выбирает значение параметра = "fblue", цвет шрифта будет синим?
Аналогично, если пользователь выбирает значение = "size1" для размера шрифта 1, как
мне изменить шрифт на основе выбора пользователя, так как это переключатель
Я думаю, что только значение будет отправлено в скрипт php, в этом случае size1?
Раздел со скриптом php будет находиться в отдельном отдельном файле .php и не будет
включенный в html, это было только для того, чтобы показать, как выглядит раздел .php скрипта.
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html;charset=utf-8" />
<title>
Webpagegenerator
</title>
</head>
<body>
<center>
<h1>Web Page Generator</h1>
<h3>Generates a web page based on user choice:</h3>
<form method = "post"
action = "webpagegene.php">
<h3>User inputs text body: </h3>
<textarea name = "textbody"
rows = "10"
cols = "40">
</textarea>
<br/>
<br/>
<table border = "2" >
<tr>
<td><h3>Font Color</h3></td>
<td colspan = "2"><h3>Background Color</h3></td>
</tr>
<tr>
<td>
<!--How do I fix this so that when php calls $fontcolor
and the user selects the option value = "fblue" the font color will be blue?-->
<select name = "fontcolor">
<option value = "fblue">Blue</option>
<option value = "fred">Red </option>
<option value = "fgreen">White</option>
</select>
</td>
<td>
<select size = "5"
name = "backgroundcolor">
<option value = "byellow">Yellow</option>
<option value = "bsilver">Silver</option>
<option value = "bmaroon">Maroon</option>
<option value = "bpink">Pink</option>
</select>
</td>
<!--Likewise, if the user selects the value = "size1" for Font Size 1, how
do I change the font based on the user selection, since this is a radio button
I think only the value will be sent to the php script, in this case size1?-->
<td>
<input type = "radio"
name = "sizeType"
value = "size1"/>Font Size 1<br/>
<input type = "radio"
name = "sizeType"
value = "size2"/>Font Size 2<br/>
<input type = "radio"
name = "sizeType"
value = "size3"/>Font Size 3<br/>
</td>
</tr>
</table>
<br/>
<input type = "submit" value = "show me"/>
<br/>
<br/>
</form>
<?php
// The php script seems to work; however, in terms of
// the script manipulating attributes such as changing
// the font, color or background when requested by the user, it
// does not seem to yield any results :-(.
// I can however have the user type text into the text field, but this is not
// enough, I want to be able to manipulate it-change it's font size, font color
// and the background color for the text.
$backgroundcolor = $_REQUEST["backgroundcolor"];
$fontcolor = $_REQUEST["fontcolor"];
$textbody = $_REQUEST["textbody"];
$sizeType = $_REQUEST["sizeType"];
$theStyle = <<< HERE
"$textbody$fontcolor$sizeType"
HERE;
print $textbody;
?>
</center>
</body>
</html>