-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy paths2.define.materialprops.php
109 lines (87 loc) · 2.67 KB
/
s2.define.materialprops.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
105
106
107
108
<?php
if(isset($_GET["id"])) {
$id = htmlspecialchars($_GET["id"]);
}
?>
<script type="text/javascript">
$(document).ready(function() {
var InputsWrapper = $("#inputs");
var AddButton = $("#addButton");
var x = InputsWrapper.length;
var FieldCount = 1;
$(AddButton).click(function (e) {
FieldCount++;
$(InputsWrapper).append('<div><label>A: </label><input name="A[]" type="text" class="mat"> m <sup>2 </sup><label> I: </label><input name="I[]" type="text" class="mat"> m <sup>4 </sup><label> E: </label><input name="E[]" type="text" class="mat"> MPa</sup><a href="#" class="removeclass">×</a><br></div>');
x++;
});
$("body").on("click",".removeclass", function(e) {
if (x>1) {
$(this).parent('div').remove();
x--;
}
return false;
});
});
</script>
<?php
if (isset($_POST["saveAndContinue"])) {
$allFieldsCompleted = true;
foreach ($_POST["A"] as $A) {
if(!is_numeric($A)) { $allFieldsCompleted = false; }
}
foreach ($_POST["I"] as $I) {
if(!is_numeric($I)) { $allFieldsCompleted = false; }
}
foreach ($_POST["E"] as $E) {
if(!is_numeric($E)) { $allFieldsCompleted = false; }
}
if(!$allFieldsCompleted) {
echo "You have entered missed/wrong inputs.";
die();
}
else {
$fp = fopen('input_files/matprops_'.$id.'.csv', 'a');
$numNodes = count($_POST["A"]);
for ($i=1; $i <=$numNodes; $i++) {
$row = $i.",".$_POST["A"][$i-1].",".$_POST["I"][$i-1].",".$_POST["E"][$i-1];
fwrite($fp, $row."\r\n");
}
fclose($fp);
header("Location: pre_process.php?nodes&matprops&id=".$id);
}
}
if(isset($_POST["previousStep"])) {
header("Location: pre_process.php?id=".$id);
}
?>
<ul id="steps">
<li class="step">Step 1: Define Nodal Points</li>
<li class="step current">Step 2: Define Material Properties</li>
<li class="step">Step 3: Define Members</li>
<li class="step">Step 4: Define Boundary Conditions</li>
<li class="step">Step 5: Define Loads</li>
<li class="step">Step 6: Run Analysis</li>
</ul>
<hr/>
<div class="clear"></div>
<p id="info">
A: Cross-sectional area,
I: Moment of Inertia,
E: Modulus of Elasticity
</p>
<div class="clear"></div>
<form action="" method="post">
<div id="inputs">
<br>
<div>
<label>A: </label><input name="A[]" type="text" class="mat"> m <sup>2</sup>
<label>I: </label><input name="I[]" type="text" class="mat"> m <sup>4</sup>
<label>E: </label><input name="E[]" type="text" class="mat"> MPa
<a href="#" class="removeclass">×</a>
<br>
</div>
</div>
<input id="addButton" name="add" type="button" value="Add More">
<hr/>
<input class="nextstep" name="saveAndContinue" type="submit" value="Next Step >">
</form>