PonyS,
<!doctype html>
<html>
<head>
<meta charset="utf-8" />
<title></title>
<style>
.select {
background: red;
}
</style>
</head>
<body>
<p class="price">1</p>
<p class="price">2</p>
<p class="price">3</p>
<p class="price">4</p>
<p class="price">5</p>
<p class="price">6</p>
<p class="price">7</p>
<p class="price">8</p>
<p class="price">9</p>
<p class="price">10</p>
<input type="hidden" value="5" />
<input type="text" value="">
<script src="https://code.jquery.com/jquery-2.1.4.js"></script>
<script>
var count = $('input[type=hidden]').val();
$('.price').click(function() {
$(this).toggleClass('select', $('.select').length < count && !$(this).is('.select'));
var arr = [];
$('.price').each(function(i,el){
$(el).is('.select') && arr.push(++i)
});
$('input[type=text]').val(arr)
});
</script>
</body>
</html>