Merge branch 'master' of git.elab.kth.se:marek/Twitch-grabs-candy
This commit is contained in:
+31
-28
@@ -1,36 +1,39 @@
|
||||
|
||||
$(document).ready(function(){
|
||||
|
||||
var quantitiy=0;
|
||||
$('.quantity-right-plus').click(function(e){
|
||||
|
||||
// Stop acting like a button
|
||||
e.preventDefault();
|
||||
// Get the field name
|
||||
var quantity = parseInt($('#quantity').val());
|
||||
|
||||
// If is not undefined
|
||||
|
||||
$('#quantity').val(quantity + 1);
|
||||
|
||||
|
||||
// Increment
|
||||
|
||||
});
|
||||
|
||||
$('.quantity-left-minus').click(function(e){
|
||||
// Stop acting like a button
|
||||
e.preventDefault();
|
||||
// Get the field name
|
||||
var quantity = parseInt($('#quantity').val());
|
||||
|
||||
// If is not undefined
|
||||
$('.quantity-right-plus').click(function(e){
|
||||
|
||||
// Increment
|
||||
if(quantity>0){
|
||||
$('#quantity').val(quantity - 1);
|
||||
}
|
||||
});
|
||||
// Stop acting like a button
|
||||
e.preventDefault();
|
||||
// Get the field name
|
||||
var quantity = parseInt( $(this).parent().siblings('input').val() ) ;
|
||||
|
||||
// If is not undefined
|
||||
|
||||
// $('#quantity').val(quantity + 1);
|
||||
|
||||
$(this).parent().siblings('input').val(quantity + 1)
|
||||
|
||||
|
||||
// Increment
|
||||
|
||||
});
|
||||
|
||||
$('.quantity-left-minus').click(function(e){
|
||||
// Stop acting like a button
|
||||
e.preventDefault();
|
||||
// Get the field name
|
||||
var quantity = parseInt( $(this).parent().siblings('input').val() ) ;
|
||||
|
||||
// If is not undefined
|
||||
|
||||
// Increment
|
||||
if(quantity>0){
|
||||
$(this).parent().siblings('input').val(quantity - 1);
|
||||
}
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
function submitOrder(){
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
<title>Alepa Twitch Grabs Candy</title>
|
||||
<script src="//code.jquery.com/jquery-1.11.1.min.js"></script>
|
||||
<script type="text/javascript" src="{{url_for('static', filename='picker.js')}}"></script>
|
||||
@@ -13,7 +14,7 @@
|
||||
|
||||
<div class="container">
|
||||
<div class="row">
|
||||
<h2>Simple Quantity increment buttons with Javascript </h2>
|
||||
<h2>Choose your sweets with a wicked system made out of an awesome humanless deployment process</h2>
|
||||
<div class="col-lg-2">
|
||||
Tasty treats
|
||||
<div class="input-group">
|
||||
@@ -84,10 +85,10 @@
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="col-lg-2">
|
||||
<div class="input-group">
|
||||
<button class="btn btn-magick" onClick="submitOrder()">Place sweet order!</button>
|
||||
</div>
|
||||
<div class="col-lg-2 center-block ">
|
||||
<div class="input-group center-block">
|
||||
<button class="btn btn-magick center-block" onClick="submitOrder()">Place sweet order!</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user