"Fontawesome Star Bootstrap Review Form"
Bootstrap 4.1.1 Snippet by jamessc0tt

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
<link href="//maxcdn.bootstrapcdn.com/bootstrap/4.1.1/css/bootstrap.min.css" rel="stylesheet" id="bootstrap-css">
<script src="//maxcdn.bootstrapcdn.com/bootstrap/4.1.1/js/bootstrap.min.js"></script>
<script src="//cdnjs.cloudflare.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
<!------ Include the above in your HEAD tag ---------->
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css" integrity="sha384-wvfXpqpZZVQGK6TAh5PVlGOfQNHSoD2xbE+QkPxCAFlNEevoEH3Sl0sibVcOQVnN" crossorigin="anonymous">
<div class="container">
<div class="card" style="margin-top:15px;">
<div class="card-body">
<h5 class="text-dark">Submit A Review</h5>
<p class="text-secondary">We pride ourselves on being there when you need us most. Your honest feedback helps our team improve.</p>
<div class="star-area">
<h1>
<i class="fa fa-star-o" aria-hidden="true" id="star_review" data-number="1"></i>
<i class="fa fa-star-o" aria-hidden="true" id="star_review" data-number="2"></i>
<i class="fa fa-star-o" aria-hidden="true" id="star_review" data-number="3"></i>
<i class="fa fa-star-o" aria-hidden="true" id="star_review" data-number="4"></i>
<i class="fa fa-star-o" aria-hidden="true" id="star_review" data-number="5"></i>
</h1>
</div>
<div class="review-area" style="display:none;">
<form>
<input type="hidden" name="stars" id="star_input" value="0">
<textarea class="form-control" rows="3" style="resize: none"></textarea>
<span class="float-right" style="margin-top:15px;line-height:35px;">
<span id="stars_confirm">
</span>
<button class="btn btn-success float-right" type="submit" style="margin-left:20px;">Submit</button>
</span>
</form>
</div>
</div>
</div>
</div>
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
1
2
3
4
5
6
7
8
9
10
11
12
.star-area {
text-align:center;
}
.fa-star-o {
color: #212529;
cursor: pointer;
}
.fa-star {
color: #FFD700;
cursor: pointer;
}
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
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
$( document ).ready(function() {
document.querySelectorAll('#star_review').forEach(function(element) {
element.addEventListener("mouseenter", function(event) {
$('#stars_confirm').html('');
var stars = event.target.dataset.number;
$('#star_input').val(stars);
var count = 0;
document.querySelectorAll('#star_review').forEach(function(el) {
if (count < stars) {
$(el).removeClass('fa-star-o');
$(el).addClass('fa-star');
$('#stars_confirm').append('<i class="fa fa-star" aria-hidden="true" style="color:#212529 !important"></i>');
} else {
$(el).removeClass('fa-star');
$(el).addClass('fa-star-o');
}
count = count+1;
});
});
element.addEventListener("click", function(event) {
console.log('clicked')
$('.star-area').hide();
$('.review-area').fadeIn();
});
element.addEventListener("mouseleave", function(event) {
document.querySelectorAll('#star_review').forEach(function(el) {
$(el).removeClass('fa-star');
$(el).addClass('fa-star-o');
});
});
});
});
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

Related: See More


Questions / Comments: