Jeg er i gang med at lave en regnemaskine hvor man selv skal
kunne vælge hvilke regnemetoder der skal komme i en bestemt
rækkefølge.
Jeg har dog problemer på de tredje side, da jeg skal have lavet
ordet "plus","minus","gange" eller "divider" om til "+","-","*"
eller "/".
Her kommer koden:
Side 1:
<html>
<head>
<title>Regnemaskine</title>
</head>
<body>
<form action="regn.php" method="post">
Gruppe 1:
<br>
<select name="boxone" size="1">
<option value="plus">Plus</option>
<option value="minus">Minus</option>
<option value="gange">Gange</option>
<option value="divider">Divider</option>
</select>
<br>
<select name="boxtwo" size="1">
<option value="plus">Plus</option>
<option value="minus">Minus</option>
<option value="gange">Gange</option>
<option value="divider">Divider</option>
</select>
<br>
<select name="boxthree" size="1">
<option value="plus">Plus</option>
<option value="minus">Minus</option>
<option value="gange">Gange</option>
<option value="divider">Divider</option>
</select>
<br>
Gruppe 2:
<br>
<select name="boxfour" size="1">
<option value="plus">Plus</option>
<option value="minus">Minus</option>
<option value="gange">Gange</option>
<option value="divider">Divider</option>
</select>
<br>
<select name="boxfive" size="1">
<option value="plus">Plus</option>
<option value="minus">Minus</option>
<option value="gange">Gange</option>
<option value="divider">Divider</option>
</select>
<br>
<select name="boxsix" size="1">
<option value="plus">Plus</option>
<option value="minus">Minus</option>
<option value="gange">Gange</option>
<option value="divider">Divider</option>
</select>
<input type="submit" value="Send">
</form>
</body>
</html>
Side 2:
<html>
<head>
<title>Regnemaskine</title>
<style type="text/css">
font-family: verdana;
font-size: 9;
</style>
</head>
<body>
Plus:
<p>
<form action="regn2.php" method="post">
<input type="text" name="plus1" style="border: 1px solid
#A4D6FF"> +
<input type="text" name="plus2" style="border: 1px solid
#A4D6FF"> +
<input type="text" name="plus3" style="border: 1px solid
#A4D6FF">
<p>
Minus:
<p>
<input type="text" name="minus1" style="border: 1px solid
#A4D6FF"> -
<input type="text" name="minus2" style="border: 1px solid
#A4D6FF"> -
<input type="text" name="minus3" style="border: 1px solid
#A4D6FF">
<p>
Gange:
<p>
<input type="text" name="gange1" style="border: 1px solid
#A4D6FF"> *
<input type="text" name="gange2" style="border: 1px solid
#A4D6FF">
<p>
Divider:
<p>
<input type="text" name="divider1" style="border: 1px solid
#A4D6FF"> /
<input type="text" name="divider2" style="border: 1px solid
#A4D6FF">
<hr>
<?
print("<input type='hidden' value='$boxone' name='boxone'");
print("<input type='hidden' value='$boxtwo' name='boxtwo'");
print("<input type='hidden' value='$boxthree' name='boxthree'");
print("<input type='hidden' value='$boxfour' name='boxfour'");
print("<input type='hidden' value='$boxfive' name='boxfive'");
print("<input type='hidden' value='$boxsix' name='boxsix'");
print("<input type='text' name='custom0' style='border: 1px solid
#A4D6FF'>
$boxone <input type='text' name='custom1' style='border: 1px
solid #A4D6FF'>
$boxtwo <input type='text' name='custom2' style='border: 1px
solid #A4D6FF'>
$boxthree <input type='text' name='custom3' style='border: 1px
solid #A4D6FF'>
<p>
$boxfour <input type='text' name='custom4' style='border: 1px
solid #A4D6FF'>
$boxfive <input type='text' name='custom5' style='border: 1px
solid #A4D6FF'>
$boxsix <input type='text' name='custom6' style='border: 1px
solid #A4D6FF'>
<input type='submit' value='Send'>"
);
?>
</form>
</body>
</html>
Side 3:
<html>
<head>
<title>Regnemaskine</title>
</head>
<body>
<?
$regn1 = $plus1 + $plus2 + $plus3;
$regn2 = $minus1 - $minus2 - $minus3;
$regn3 = $gange1 * $gange2;
$regn4 = $divider1/$divider2;
print("Resultat af plus: $regn1");
print("<p>");
print("Resultatet af minus: $regn2");
print("<p>");
print("Resultatet af gange: $regn3");
print("<p>");
print("Resultatet af divider: $regn4");
print("<p>");
$plus = '+';
$minus = '-';
$gange = '*';
$divider = '/';
print($boxone);
if($boxone = 'plus'){
$boxone = $plus;
}
if($boxone = 'minus'){
$boxone = $minus;
}
if($boxone = 'gange'){
$boxone = $gange;
}
if($boxone = 'divider'){
$boxone = $divider;
}
print($boxone);
print($boxtwo);
print($boxthree);
print($boxfour);
print($boxfive);
print($boxsix);
?>
</body>
</html>
--
Vil du lære at kode HTML, XHTML, CSS, SSI eller ASP?
- Pædagogiske tutorials på dansk
- Kom godt i gang med koderne
KLIK HER! =>
http://www.html.dk/tutorials