Star Rating System
Ik probeer een star rating system goed in elkaar te zetten maar het lukt mij niet.
Ik heb de volgende code gebruikt:
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
105
106
107
108
109
110
111
112
113
114
115
116
117
118
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
109
110
111
112
113
114
115
116
117
118
<style>
.star-rating {
font-size: 0;
white-space: nowrap;
display: inline-block;
width: 250px;
height: 50px;
overflow: hidden;
position: relative;
background: url('data:image/svg+xml;base64,PHN2ZyB2ZXJzaW9uPSIxLjEiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIgeG1sbnM6eGxpbms9Imh0dHA6Ly93d3cudzMub3JnLzE5OTkveGxpbmsiIHg9IjBweCIgeT0iMHB4IiB3aWR0aD0iMjBweCIgaGVpZ2h0PSIyMHB4IiB2aWV3Qm94PSIwIDAgMjAgMjAiIGVuYWJsZS1iYWNrZ3JvdW5kPSJuZXcgMCAwIDIwIDIwIiB4bWw6c3BhY2U9InByZXNlcnZlIj48cG9seWdvbiBmaWxsPSIjREREREREIiBwb2ludHM9IjEwLDAgMTMuMDksNi41ODMgMjAsNy42MzkgMTUsMTIuNzY0IDE2LjE4LDIwIDEwLDE2LjU4MyAzLjgyLDIwIDUsMTIuNzY0IDAsNy42MzkgNi45MSw2LjU4MyAiLz48L3N2Zz4=');
background-size: contain;
}
.star-rating i {
opacity: 0;
position: absolute;
left: 0;
top: 0;
height: 100%;
width: 20%;
z-index: 1;
background: url('data:image/svg+xml;base64,PHN2ZyB2ZXJzaW9uPSIxLjEiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIgeG1sbnM6eGxpbms9Imh0dHA6Ly93d3cudzMub3JnLzE5OTkveGxpbmsiIHg9IjBweCIgeT0iMHB4IiB3aWR0aD0iMjBweCIgaGVpZ2h0PSIyMHB4IiB2aWV3Qm94PSIwIDAgMjAgMjAiIGVuYWJsZS1iYWNrZ3JvdW5kPSJuZXcgMCAwIDIwIDIwIiB4bWw6c3BhY2U9InByZXNlcnZlIj48cG9seWdvbiBmaWxsPSIjRkZERjg4IiBwb2ludHM9IjEwLDAgMTMuMDksNi41ODMgMjAsNy42MzkgMTUsMTIuNzY0IDE2LjE4LDIwIDEwLDE2LjU4MyAzLjgyLDIwIDUsMTIuNzY0IDAsNy42MzkgNi45MSw2LjU4MyAiLz48L3N2Zz4=');
background-size: contain;
}
.star-rating input {
-moz-appearance: none;
-webkit-appearance: none;
opacity: 0;
display: inline-block;
width: 20%;
height: 100%;
margin: 0;
padding: 0;
z-index: 2;
position: relative;
}
.star-rating input:hover + i,
.star-rating input:checked + i {
opacity: 1;
}
.star-rating i ~ i {
width: 40%;
}
.star-rating i ~ i ~ i {
width: 60%;
}
.star-rating i ~ i ~ i ~ i {
width: 80%;
}
.star-rating i ~ i ~ i ~ i ~ i {
width: 100%;
}
.choice {
position: fixed;
top: 0;
left: 0;
right: 0;
text-align: center;
padding: 20px;
display: block;
}
*,
::after,
::before {
height: 100%;
padding: 0;
margin: 0;
box-sizing: border-box;
text-align: center;
vertical-align: middle;
}
body {
font-family: "HelveticaNeue-Light", "Helvetica Neue Light", "Helvetica Neue", Helvetica, Arial, "Lucida Grande", sans-serif;
}
body::before {
height: 100%;
content: '';
width: 0;
background: red;
vertical-align: middle;
display: inline-block;
}
</style>
<script type="text/javascript">
$(':radio').change(
function(){
$('.choice').text( this.value + ' stars' );
}
)
</script>
<form action="index.php" method="POST">
<input type="submit">
<span class="star-rating">
<input type="radio" name="waardering" value="1"><i></i>
<input type="radio" name="waardering" value="2"><i></i>
<input type="radio" name="waardering" value="3"><i></i>
<input type="radio" name="waardering" value="4"><i></i>
<input type="radio" name="waardering" value="5"><i></i>
</span><Br>
<span class="star-rating">
<input type="radio" name="goed" value="1"><i></i>
<input type="radio" name="goed" value="2"><i></i>
<input type="radio" name="goed" value="3"><i></i>
<input type="radio" name="goed" value="4"><i></i>
<input type="radio" name="goed" value="5"><i></i>
</span><br>
<span class="star-rating">
<input type="radio" name="slecht" value="1"><i></i>
<input type="radio" name="slecht" value="2"><i></i>
<input type="radio" name="slecht" value="3"><i></i>
<input type="radio" name="slecht" value="4"><i></i>
<input type="radio" name="slecht" value="5"><i></i>
</span><br>
</form>
<strong class="choice">Choose a rating</strong>
<?php
print_r($_POST);
?>
.star-rating {
font-size: 0;
white-space: nowrap;
display: inline-block;
width: 250px;
height: 50px;
overflow: hidden;
position: relative;
background: url('data:image/svg+xml;base64,PHN2ZyB2ZXJzaW9uPSIxLjEiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIgeG1sbnM6eGxpbms9Imh0dHA6Ly93d3cudzMub3JnLzE5OTkveGxpbmsiIHg9IjBweCIgeT0iMHB4IiB3aWR0aD0iMjBweCIgaGVpZ2h0PSIyMHB4IiB2aWV3Qm94PSIwIDAgMjAgMjAiIGVuYWJsZS1iYWNrZ3JvdW5kPSJuZXcgMCAwIDIwIDIwIiB4bWw6c3BhY2U9InByZXNlcnZlIj48cG9seWdvbiBmaWxsPSIjREREREREIiBwb2ludHM9IjEwLDAgMTMuMDksNi41ODMgMjAsNy42MzkgMTUsMTIuNzY0IDE2LjE4LDIwIDEwLDE2LjU4MyAzLjgyLDIwIDUsMTIuNzY0IDAsNy42MzkgNi45MSw2LjU4MyAiLz48L3N2Zz4=');
background-size: contain;
}
.star-rating i {
opacity: 0;
position: absolute;
left: 0;
top: 0;
height: 100%;
width: 20%;
z-index: 1;
background: url('data:image/svg+xml;base64,PHN2ZyB2ZXJzaW9uPSIxLjEiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIgeG1sbnM6eGxpbms9Imh0dHA6Ly93d3cudzMub3JnLzE5OTkveGxpbmsiIHg9IjBweCIgeT0iMHB4IiB3aWR0aD0iMjBweCIgaGVpZ2h0PSIyMHB4IiB2aWV3Qm94PSIwIDAgMjAgMjAiIGVuYWJsZS1iYWNrZ3JvdW5kPSJuZXcgMCAwIDIwIDIwIiB4bWw6c3BhY2U9InByZXNlcnZlIj48cG9seWdvbiBmaWxsPSIjRkZERjg4IiBwb2ludHM9IjEwLDAgMTMuMDksNi41ODMgMjAsNy42MzkgMTUsMTIuNzY0IDE2LjE4LDIwIDEwLDE2LjU4MyAzLjgyLDIwIDUsMTIuNzY0IDAsNy42MzkgNi45MSw2LjU4MyAiLz48L3N2Zz4=');
background-size: contain;
}
.star-rating input {
-moz-appearance: none;
-webkit-appearance: none;
opacity: 0;
display: inline-block;
width: 20%;
height: 100%;
margin: 0;
padding: 0;
z-index: 2;
position: relative;
}
.star-rating input:hover + i,
.star-rating input:checked + i {
opacity: 1;
}
.star-rating i ~ i {
width: 40%;
}
.star-rating i ~ i ~ i {
width: 60%;
}
.star-rating i ~ i ~ i ~ i {
width: 80%;
}
.star-rating i ~ i ~ i ~ i ~ i {
width: 100%;
}
.choice {
position: fixed;
top: 0;
left: 0;
right: 0;
text-align: center;
padding: 20px;
display: block;
}
*,
::after,
::before {
height: 100%;
padding: 0;
margin: 0;
box-sizing: border-box;
text-align: center;
vertical-align: middle;
}
body {
font-family: "HelveticaNeue-Light", "Helvetica Neue Light", "Helvetica Neue", Helvetica, Arial, "Lucida Grande", sans-serif;
}
body::before {
height: 100%;
content: '';
width: 0;
background: red;
vertical-align: middle;
display: inline-block;
}
</style>
<script type="text/javascript">
$(':radio').change(
function(){
$('.choice').text( this.value + ' stars' );
}
)
</script>
<form action="index.php" method="POST">
<input type="submit">
<span class="star-rating">
<input type="radio" name="waardering" value="1"><i></i>
<input type="radio" name="waardering" value="2"><i></i>
<input type="radio" name="waardering" value="3"><i></i>
<input type="radio" name="waardering" value="4"><i></i>
<input type="radio" name="waardering" value="5"><i></i>
</span><Br>
<span class="star-rating">
<input type="radio" name="goed" value="1"><i></i>
<input type="radio" name="goed" value="2"><i></i>
<input type="radio" name="goed" value="3"><i></i>
<input type="radio" name="goed" value="4"><i></i>
<input type="radio" name="goed" value="5"><i></i>
</span><br>
<span class="star-rating">
<input type="radio" name="slecht" value="1"><i></i>
<input type="radio" name="slecht" value="2"><i></i>
<input type="radio" name="slecht" value="3"><i></i>
<input type="radio" name="slecht" value="4"><i></i>
<input type="radio" name="slecht" value="5"><i></i>
</span><br>
</form>
<strong class="choice">Choose a rating</strong>
<?php
print_r($_POST);
?>
Het design is best irritant en ik moet helemaal nog ombouwen voor mysql, maar hij herkent de post niet.
Weet een van jullie misschien de oplossing? Of een makkelijkere / betere die al voor mysql is?
Als je de afbeelding zou kunnen uploaden kan ik even kijken wat er precies verkeerd gaat. Ik heb geen idee welke afbeelding je gebruikt namelijk.
Het probleem is hem dat hij de submit knop niet accepteert.
Maar weet jij misschien een makkelijkere/betere/snellere oplossing?
Gewijzigd op 24/12/2014 11:16:31 door Randy vsf
Name is niet verplicht ook geprobeerd maar hoort niks uit te maken, en dat maakte ook niks uit
zo zou het moeten werken:
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
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
<form action="index.php" method="POST">
<input type="submit">
<span class="star-rating">
<fieldset>
<input type="radio" name="waardering" value="1"><i></i>
<input type="radio" name="waardering" value="2"><i></i>
<input type="radio" name="waardering" value="3"><i></i>
<input type="radio" name="waardering" value="4"><i></i>
<input type="radio" name="waardering" value="5"><i></i>
</fieldset>
</span><Br>
<span class="star-rating">
<fieldset>
<input type="radio" name="goed" value="1"><i></i>
<input type="radio" name="goed" value="2"><i></i>
<input type="radio" name="goed" value="3"><i></i>
<input type="radio" name="goed" value="4"><i></i>
<input type="radio" name="goed" value="5"><i></i>
</fieldset>
</span><br>
<span class="star-rating">
<fieldset>
<input type="radio" name="slecht" value="1"><i></i>
<input type="radio" name="slecht" value="2"><i></i>
<input type="radio" name="slecht" value="3"><i></i>
<input type="radio" name="slecht" value="4"><i></i>
<input type="radio" name="slecht" value="5"><i></i>
</fieldset>
</span><br>
</form>
<strong class="choice">Choose a rating</strong>
<input type="submit">
<span class="star-rating">
<fieldset>
<input type="radio" name="waardering" value="1"><i></i>
<input type="radio" name="waardering" value="2"><i></i>
<input type="radio" name="waardering" value="3"><i></i>
<input type="radio" name="waardering" value="4"><i></i>
<input type="radio" name="waardering" value="5"><i></i>
</fieldset>
</span><Br>
<span class="star-rating">
<fieldset>
<input type="radio" name="goed" value="1"><i></i>
<input type="radio" name="goed" value="2"><i></i>
<input type="radio" name="goed" value="3"><i></i>
<input type="radio" name="goed" value="4"><i></i>
<input type="radio" name="goed" value="5"><i></i>
</fieldset>
</span><br>
<span class="star-rating">
<fieldset>
<input type="radio" name="slecht" value="1"><i></i>
<input type="radio" name="slecht" value="2"><i></i>
<input type="radio" name="slecht" value="3"><i></i>
<input type="radio" name="slecht" value="4"><i></i>
<input type="radio" name="slecht" value="5"><i></i>
</fieldset>
</span><br>
</form>
<strong class="choice">Choose a rating</strong>
Gewijzigd op 24/12/2014 11:27:06 door Henk de Vriep
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
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
<form action="rating.php" method="POST">
<span class="star-rating">
<input type="radio" name="waardering" value="1"><i></i>
<input type="radio" name="waardering" value="2"><i></i>
<input type="radio" name="waardering" value="3"><i></i>
<input type="radio" name="waardering" value="4"><i></i>
<input type="radio" name="waardering" value="5"><i></i>
</span><Br>
<span class="star-rating">
<input type="radio" name="goed" value="1"><i></i>
<input type="radio" name="goed" value="2"><i></i>
<input type="radio" name="goed" value="3"><i></i>
<input type="radio" name="goed" value="4"><i></i>
<input type="radio" name="goed" value="5"><i></i>
</span><br>
<span class="star-rating">
<input type="radio" name="slecht" value="1"><i></i>
<input type="radio" name="slecht" value="2"><i></i>
<input type="radio" name="slecht" value="3"><i></i>
<input type="radio" name="slecht" value="4"><i></i>
<input type="radio" name="slecht" value="5"><i></i>
</span><br>
<input type="submit">
</form>
<strong class="choice">Choose a rating</strong>
<?php
print_r($_POST);
?>
<span class="star-rating">
<input type="radio" name="waardering" value="1"><i></i>
<input type="radio" name="waardering" value="2"><i></i>
<input type="radio" name="waardering" value="3"><i></i>
<input type="radio" name="waardering" value="4"><i></i>
<input type="radio" name="waardering" value="5"><i></i>
</span><Br>
<span class="star-rating">
<input type="radio" name="goed" value="1"><i></i>
<input type="radio" name="goed" value="2"><i></i>
<input type="radio" name="goed" value="3"><i></i>
<input type="radio" name="goed" value="4"><i></i>
<input type="radio" name="goed" value="5"><i></i>
</span><br>
<span class="star-rating">
<input type="radio" name="slecht" value="1"><i></i>
<input type="radio" name="slecht" value="2"><i></i>
<input type="radio" name="slecht" value="3"><i></i>
<input type="radio" name="slecht" value="4"><i></i>
<input type="radio" name="slecht" value="5"><i></i>
</span><br>
<input type="submit">
</form>
<strong class="choice">Choose a rating</strong>
<?php
print_r($_POST);
?>
Gewijzigd op 24/12/2014 11:29:00 door Randy vsf
<strong class="choice">Choose a rating</strong>
Die blokeerde de submit knop