rekenmachine
ik heb tot nou toe /, *, -, +. maar ik moet ook wortel en kwadraat erin verwerken dit lukt mij niet wat ik ook probeer hebben jullie misschien tips.
Code (php)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
<!DOCTYPE html>
<html>
<head>
<title>calculator</title>
<link rel="stylesheet" type="text/css" href="calculator.css">
</head>
<body>
<?php
ini_set('display_errors',0);
if( isset( $_REQUEST['calculate'] ))
{
$operator=$_REQUEST['operator'];
if($operator=="+")
{
$add1 = $_REQUEST['fvalue'];
$add2 = $_REQUEST['lvalue'];
$res= $add1+$add2;
}
if($operator=="-")
{
$add1 = $_REQUEST['fvalue'];
$add2 = $_REQUEST['lvalue'];
$res= $add1-$add2;
}
if($operator=="*")
{
$add1 = $_REQUEST['fvalue'];
$add2 = $_REQUEST['lvalue'];
$res =$add1*$add2;
}
if($operator=="/")
{
$add1 = $_REQUEST['fvalue'];
$add2 = $_REQUEST['lvalue'];
$res= $add1/$add2;
}
if($operator=="^")
{
$add1 = $_REQUEST['fvalue'];
$add2 = $_REQUEST['lvalue'];
$res= $add1^$add2;
}
if($_REQUEST['fvalue']==NULL && $_REQUEST['lvalue']==NULL)
{
echo "<script language=javascript> alert(\"Please Enter values.\");</script>";
}
else if($_REQUEST['fvalue']==NULL)
{
echo "<script language=javascript> alert(\"Please Enter First value.\");</script>";
}
else if($_REQUEST['lvalue']==NULL)
{
echo "<script language=javascript> alert(\"Please Enter second value.\");</script>";
}
}
?>
<form>
<table >
<tr>
<td>enter first number</td>
<td colspan="1">
<input name="fvalue" type="text" style="color:red"/></td>
<tr>
<td>select operator</td>
<td>
<select name="operator" style="width: 63px">
<option>+</option>
<option>-</option>
<option>*</option>
<option>/</option>
<option></option>
<option></option>
</select></td>
</tr>
<tr>
<tr>
<td style=" font-family:'Times New Roman'">Enter second Number</td>
<td class="auto-style5">
<input name="lvalue" type="text" style="color:red"/></td>
</tr>
<tr>
<td></td>
<td><input type="submit" name="calculate" value="Calculate" style="color:wheat;background-color:rosybrown" /></td>
</tr>
<tr>
<td style="">Output = </td>
<td style=""><?php echo $res;?></td>
</tr>
</table>
</form>
</body>
</html>
<html>
<head>
<title>calculator</title>
<link rel="stylesheet" type="text/css" href="calculator.css">
</head>
<body>
<?php
ini_set('display_errors',0);
if( isset( $_REQUEST['calculate'] ))
{
$operator=$_REQUEST['operator'];
if($operator=="+")
{
$add1 = $_REQUEST['fvalue'];
$add2 = $_REQUEST['lvalue'];
$res= $add1+$add2;
}
if($operator=="-")
{
$add1 = $_REQUEST['fvalue'];
$add2 = $_REQUEST['lvalue'];
$res= $add1-$add2;
}
if($operator=="*")
{
$add1 = $_REQUEST['fvalue'];
$add2 = $_REQUEST['lvalue'];
$res =$add1*$add2;
}
if($operator=="/")
{
$add1 = $_REQUEST['fvalue'];
$add2 = $_REQUEST['lvalue'];
$res= $add1/$add2;
}
if($operator=="^")
{
$add1 = $_REQUEST['fvalue'];
$add2 = $_REQUEST['lvalue'];
$res= $add1^$add2;
}
if($_REQUEST['fvalue']==NULL && $_REQUEST['lvalue']==NULL)
{
echo "<script language=javascript> alert(\"Please Enter values.\");</script>";
}
else if($_REQUEST['fvalue']==NULL)
{
echo "<script language=javascript> alert(\"Please Enter First value.\");</script>";
}
else if($_REQUEST['lvalue']==NULL)
{
echo "<script language=javascript> alert(\"Please Enter second value.\");</script>";
}
}
?>
<form>
<table >
<tr>
<td>enter first number</td>
<td colspan="1">
<input name="fvalue" type="text" style="color:red"/></td>
<tr>
<td>select operator</td>
<td>
<select name="operator" style="width: 63px">
<option>+</option>
<option>-</option>
<option>*</option>
<option>/</option>
<option></option>
<option></option>
</select></td>
</tr>
<tr>
<tr>
<td style=" font-family:'Times New Roman'">Enter second Number</td>
<td class="auto-style5">
<input name="lvalue" type="text" style="color:red"/></td>
</tr>
<tr>
<td></td>
<td><input type="submit" name="calculate" value="Calculate" style="color:wheat;background-color:rosybrown" /></td>
</tr>
<tr>
<td style="">Output = </td>
<td style=""><?php echo $res;?></td>
</tr>
</table>
</form>
</body>
</html>
- Ariën -:
Gelieve in het vervolg bij code de [code][/code]-tags gebruiken.
Hier kan je meer lezen over de mogelijke opmaakcodes.
Alvast bedankt!
Hier kan je meer lezen over de mogelijke opmaakcodes.
Alvast bedankt!
Gewijzigd op 02/11/2016 22:09:06 door - Ariën -
adoptive solution nee dat helpt ook niet
Ik heb je rekenmachine zo werkend gekregen. Kijk maar.
En passant nog wat rotzooi eruit gehaald en wat nuttigs toegevoegd :
Code (php)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
<!DOCTYPE html>
<html>
<head>
<title>calculator</title>
<link rel="stylesheet" type="text/css" href="calculator.css">
</head>
<body>
<?php
ini_set('display_errors',0);
if( isset( $_REQUEST['calculate'] )) {
$operator=$_REQUEST['operator'];
// optellen
if($operator=="+") {
$add1 = $_REQUEST['fvalue'];
$add2 = $_REQUEST['lvalue'];
$res= $add1+$add2;
}
// aftrekken
if($operator=="-") {
$add1 = $_REQUEST['fvalue'];
$add2 = $_REQUEST['lvalue'];
$res= $add1-$add2;
}
// vermenigvuldigen
if($operator=="*") {
$add1 = $_REQUEST['fvalue'];
$add2 = $_REQUEST['lvalue'];
$res =$add1*$add2;
}
// delen
if($operator=="/") {
$add1 = $_REQUEST['fvalue'];
$add2 = $_REQUEST['lvalue'];
$res= $add1/$add2;
}
// machtverheffen
if($operator=="^") {
$add1 = $_REQUEST['fvalue'];
$add2 = $_REQUEST['lvalue'];
$res= pow($add1,$add2);
}
// wortel
if($operator=="~") {
$add1 = $_REQUEST['fvalue'];
$add2 = $_REQUEST['lvalue'];
$res= sqrt($add1);
}
if($_REQUEST['fvalue']==NULL && $_REQUEST['lvalue']==NULL) {
echo "<script language=javascript> alert(\"Please Enter values.\");</script>";
} else if($_REQUEST['fvalue']==NULL) {
echo "<script language=javascript> alert(\"Please Enter First value.\");</script>";
} else if($_REQUEST['lvalue']==NULL) {
echo "<script language=javascript> alert(\"Please Enter second value.\");</script>";
}
}
?>
<form>
<table border='1'>
<tr>
<td>Eerste getal</td>
<td colspan="1">
<input name="fvalue" type="text" value="<?php echo $add1; ?>"/>
</td>
</tr>
<tr>
<td>Operator</td>
<td>
<select name="operator" style="width: 20px">
<option <?php echo ($operator == "+" ? 'selected' : ''); ?> >+</option>
<option <?php echo ($operator == "-" ? 'selected' : ''); ?> >-</option>
<option <?php echo ($operator == "*" ? 'selected' : ''); ?> >*</option>
<option <?php echo ($operator == "/" ? 'selected' : ''); ?> >/</option>
<option <?php echo ($operator == "^" ? 'selected' : ''); ?> >^</option>
<option <?php echo ($operator == "~" ? 'selected' : ''); ?> >~</option>
</select>
</td>
</tr>
<tr>
<td>Tweede getal</td>
<td>
<input name="lvalue" type="text" value="<?php echo $add2; ?>" />
</td>
</tr>
<tr>
<td></td>
<td>
<input type="submit" name="calculate" value="Calculate" />
</td>
</tr>
<tr>
<td>Resultaat</td>
<td>
<?php echo $res;?>
</td>
</tr>
</table>
</form>
</body>
</html>
<html>
<head>
<title>calculator</title>
<link rel="stylesheet" type="text/css" href="calculator.css">
</head>
<body>
<?php
ini_set('display_errors',0);
if( isset( $_REQUEST['calculate'] )) {
$operator=$_REQUEST['operator'];
// optellen
if($operator=="+") {
$add1 = $_REQUEST['fvalue'];
$add2 = $_REQUEST['lvalue'];
$res= $add1+$add2;
}
// aftrekken
if($operator=="-") {
$add1 = $_REQUEST['fvalue'];
$add2 = $_REQUEST['lvalue'];
$res= $add1-$add2;
}
// vermenigvuldigen
if($operator=="*") {
$add1 = $_REQUEST['fvalue'];
$add2 = $_REQUEST['lvalue'];
$res =$add1*$add2;
}
// delen
if($operator=="/") {
$add1 = $_REQUEST['fvalue'];
$add2 = $_REQUEST['lvalue'];
$res= $add1/$add2;
}
// machtverheffen
if($operator=="^") {
$add1 = $_REQUEST['fvalue'];
$add2 = $_REQUEST['lvalue'];
$res= pow($add1,$add2);
}
// wortel
if($operator=="~") {
$add1 = $_REQUEST['fvalue'];
$add2 = $_REQUEST['lvalue'];
$res= sqrt($add1);
}
if($_REQUEST['fvalue']==NULL && $_REQUEST['lvalue']==NULL) {
echo "<script language=javascript> alert(\"Please Enter values.\");</script>";
} else if($_REQUEST['fvalue']==NULL) {
echo "<script language=javascript> alert(\"Please Enter First value.\");</script>";
} else if($_REQUEST['lvalue']==NULL) {
echo "<script language=javascript> alert(\"Please Enter second value.\");</script>";
}
}
?>
<form>
<table border='1'>
<tr>
<td>Eerste getal</td>
<td colspan="1">
<input name="fvalue" type="text" value="<?php echo $add1; ?>"/>
</td>
</tr>
<tr>
<td>Operator</td>
<td>
<select name="operator" style="width: 20px">
<option <?php echo ($operator == "+" ? 'selected' : ''); ?> >+</option>
<option <?php echo ($operator == "-" ? 'selected' : ''); ?> >-</option>
<option <?php echo ($operator == "*" ? 'selected' : ''); ?> >*</option>
<option <?php echo ($operator == "/" ? 'selected' : ''); ?> >/</option>
<option <?php echo ($operator == "^" ? 'selected' : ''); ?> >^</option>
<option <?php echo ($operator == "~" ? 'selected' : ''); ?> >~</option>
</select>
</td>
</tr>
<tr>
<td>Tweede getal</td>
<td>
<input name="lvalue" type="text" value="<?php echo $add2; ?>" />
</td>
</tr>
<tr>
<td></td>
<td>
<input type="submit" name="calculate" value="Calculate" />
</td>
</tr>
<tr>
<td>Resultaat</td>
<td>
<?php echo $res;?>
</td>
</tr>
</table>
</form>
</body>
</html>
edit: heb het al gevonden dankjewel voor de hulp iedereen
Gewijzigd op 01/11/2016 11:52:47 door nathan monteyne