-
Notifications
You must be signed in to change notification settings - Fork 2
/
addPoll.php
85 lines (82 loc) · 2.82 KB
/
addPoll.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
<?php
include("common.php");
outHtml1("Add Poll");
?>
<script>
function add()
{
if (document.getElementById("table").rows.length < 12)
{
//alert("asdgsdg");
var row = document.getElementById("table").insertRow(-1);
var cell = row.insertCell(-1);
cell.className = "tblleft";
var text = document.createElement("span");
text.appendChild(document.createTextNode("Option"));
text.style.textDecoration = "underline";
cell.appendChild(text);
var delButton = document.createElement("input");
delButton.type = "button";
delButton.name = "delButton";
delButton.setAttribute("value","Delete");
delButton.setAttribute("onClick","del("+(document.getElementById("table").rows.length-1)+");");
delButton.style.marginLeft = "10px";
delButton.id = document.getElementById("table").rows.length-1;
cell.appendChild(delButton);
var cell = row.insertCell(-1);
cell.className = "tblright";
var inputBox = document.createElement("input");
inputBox.type = "text";
inputBox.name = "option[]";
cell.appendChild(inputBox);
}
}
function del(num)
{
document.getElementById("table").deleteRow(num);
for (i = 2; i < document.getElementById("table").rows.length; i++)
{
document.getElementById("table").rows[i].cells[0].lastChild.setAttribute("onClick","del("+i+");");
}
}
</script>
<?php
outHtml2("Add Poll:", "viewTopics.php?forumId=".$_GET['forumId']);
?>
<form action="addPollExecute.php?forumId=<?php echo $_GET['forumId']?>" method="post">
<table class="tbl" id="table">
<tr>
<td class="tblleft"><u>Poll Question</u></td>
<td class="tblright"><input type="text" name="pollQuestion"/></td>
</tr>
<tr>
<td class="tblleft"><u>Number Of Days (0 is forever)</u></td>
<td class="tblright"><input type="text" name="pollLength" value="0" /></td>
</tr>
<tr>
<td class="tblleft"><u>Option</u><input type="button" style="margin-left: 10px" name="delButton" id="2" value="Delete" onClick="del(2)" /></td>
<td class="tblright"><input type="text" name="option[]" /></td>
</tr>
<tr>
<td class="tblleft"><u>Option</u><input type="button" style="margin-left: 10px" name="delButton" id="3" value="Delete" onClick="del(3)" /></td>
<td class="tblright"><input type="text" name="option[]" /></td>
</tr>
</table>
<?php
if ($_GET['error'] == 1)
{
echo "<div class='error'>Please enter a poll question!</div>";
}
else if ($_GET['error'] == 2)
{
echo "<div class='error'>Please fill in all the visible options.</div>";
}
?>
<div class="buttons">
<input type="button" name="addOption" value="Add Option" onClick="add();" />
<input type="submit" name="submit" value="Add Poll" />
</div>
</form>
<?php
outHtml3();
?>