I'm trying to make a website with a form where users put in information and then the information is written to a <div> like a bussinesscard.
I've done it in JavaScript and now I'm trying to make it work in PHP but I'm stuck, so I need all help I can get! I think I made the variables declaration right, but how do I make the "style.fontFami ly, style.backgroun dColor" etc. and the innerHTML to work?
This is my code:
I've done it in JavaScript and now I'm trying to make it work in PHP but I'm stuck, so I need all help I can get! I think I made the variables declaration right, but how do I make the "style.fontFami ly, style.backgroun dColor" etc. and the innerHTML to work?
This is my code:
Code:
<?php print('<?xml version="1.0" encoding="UTF-8"?>') ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">
<head>
<title>Visitkort</title>
<style type="text/css">
#form1 fieldset
{
width: 400px;
padding: 20px 0px 20px 50px;
border: 1px solid #99cc00;
background-color: #e2ff8c;
}
#form1 legend
{
background-color: #e2ff8c;
padding: 2px 2px 2px 3px;
margin-left: -30px;
letter-spacing: 3px;
border: 1px solid #99cc00;
}
#showMsg
{
width: 400px;
height: 200px;
padding: 5px;
margin-top: 10px;
margin-bottom:10px;
}
#footer
{ border-top-style: solid; font-size:0.9em;
clear:both;
width:980px;
line-height:1.4em;
font-weight:400;
margin-bottom:10px;
padding-top:5px;
border-top: 1px gray;
text-align:right;
}
.valid { float: left;}
label
{
width: 4em;
float: left;
text-align: right;
display: block;
margin-right: 2.5em;
}
</style>
<?php
$userCompany = $_POST['userCompany'];
$userLname = $_POST['userLname'];
$userSname = $_POST['userSname'];
$userTitle = $_POST['userTitle'];
$userPhone = $_POST['userPhone'];
$userMail = $_POST['userMail'];
$font = $_POST['font'];
$_POST['showMsg'];.style.fontFamily = font.value;
$bgcolor = $_POST['bgcolor'];
$_POST['showMsg'];.style.backgroundColor = bgcolor.value;
$fontcolor = $_POST['fontcolor'];
$_POST['showMsg'];.style.color = fontcolor.value;
$showMessageDiv = $_POST['showMsg'];
$showMessageDiv.innerHTML = "<h1>" + userCompany + "</h1>" + "<br />" + userSname +
" " + userLname + "<br />" + userTitle + "<p>Tfn " + userPhone + "<br />E-post: " + userMail + "</p>"}
?>
</head>
<body>
<div id="form1">
<form id="inputform" action="resultat.php" method="post">
<fieldset>
<legend>Beställ ditt visitkort här</legend>
<label for="userCompany">Företag</label>
<input type="text" id="userCompany" /> <br/>
<label for="userLname">Efternamn</label>
<input type="text" id="userLname" /> <br/>
<label for="userSname">Förnamn</label>
<input type="text" id="userSname" /> <br/>
<label for="userTitle">Titel</label>
<input type="text" id="userTitle" /> <br/>
<label for="userPhone">Telefon</label>
<input type="text" id="userPhone" /> <br/>
<label for="userMail">E-post</label>
<input type="text" id="userMail" /> <br/>
<label for="bgcolor">Bakgrundsfärg</label>
<select name="bgcolor" id="bgcolor">
<option value="#00CCFF">Ljusblå</option>
<option value="#CCFF99">Ljusgul</option>
<option value="#FFFFFF">Vit</option>
<option value="#00FFFF">Turkos</option>
</select> <br />
<label for="fontcolor">Textfärg</label>
<select name="fontcolor" id="fontcolor">
<option value="#000000">Svart</option>
<option value="#0000FF">Blå</option>
<option value="#FF0000">Röd</option>
<option value="#003300">Mörkgrön</option>
</select> <br />
<label for="font">Typsnitt</label>
<select name="font" id="font">
<option value="verdana">Verdana</option>
<option value="arial">Arial</option>
<option value="tahoma">Tahoma</option>
<option value="impact">Impact</option>
</select> <br />
<input type="button" name="send" id="send" value="Skicka" onclick="showMsg()" />
<input type="button" value="Återställ" onclick="reset()" />
</fieldset>
</form>
</div>
<div id="showMsg"></div>
<div id="footer">
</div>
<div class="valid">
<a href="http://validator.w3.org/check?uri=referer"><img
src="http://www.w3.org/Icons/valid-xhtml10"
alt="Valid XHTML 1.0 Strict" height="31" width="88" /></a>
<a href="http://jigsaw.w3.org/css-validator/check/referer">
<img style="border:0;width:88px;height:31px"
src="http://jigsaw.w3.org/css-validator/images/vcss"
alt="Valid CSS!" />
</a>
</div>
</body>
</html>
Comment