BlakeEstep
5 years agoQrew Trainee
Custom code in Form
I found a bootstrap script that will display as an input number roller. The code works and is on a code page. I can only access it by using a URL Formula Field. I made it appear as a button and when clicked it pops up and shows the roller. However, the value within the roller doesn't save and there's no way to exit.
What's the best way for the number roller to input the final value into a field?
Eventually, once I get this working, this will be combined with a popup to receive multiple inputs and output as a line item. you can then hit a "+" button to create a new line item. We'll cross that bridge when we get to it though.
Bootstrap Number roller Code page:
------------------------------
BlakeE
------------------------------
What's the best way for the number roller to input the final value into a field?
Eventually, once I get this working, this will be combined with a popup to receive multiple inputs and output as a line item. you can then hit a "+" button to create a new line item. We'll cross that bridge when we get to it though.
Bootstrap Number roller Code page:
<link href="//netdna.bootstrapcdn.com/bootstrap/3.1.0/css/bootstrap.min.css" rel="stylesheet" id="bootstrap-css"> <script src="//netdna.bootstrapcdn.com/bootstrap/3.1.0/js/bootstrap.min.js"></script> <script src="//code.jquery.com/jquery-1.11.1.min.js"></script> <!------ Include the above in your HEAD tag ----------> <div class="container"> <div class="row"> <div class="col-xs-6 col-xs-offset-3"> <div class="input-group number-spinner"> <span class="input-group-btn"> <button class="btn btn-default" data-dir="dwndwndwn"><span class="glyphicon glyphicon-minus">10</span></button> </span> <span class="input-group-btn"> <button class="btn btn-default" data-dir="dwndwn"><span class="glyphicon glyphicon-minus">5</span></button> </span> <span class="input-group-btn"> <button class="btn btn-default" data-dir="dwn"><span class="glyphicon glyphicon-minus"></span></button> </span> <input type="text" class="form-control text-center" value="0"> <span class="input-group-btn"> <button class="btn btn-default" data-dir="up"><span class="glyphicon glyphicon-plus"></span></button> </span> <span class="input-group-btn"> <button class="btn btn-default" data-dir="upup"><span class="glyphicon glyphicon-plus">5</span></button> </span> <span class="input-group-btn"> <button class="btn btn-default" data-dir="upupup"><span class="glyphicon glyphicon-plus">10</span></button> </span> </div> </div> </div> </div> <script> $(document).on('click', '.number-spinner button', function () { var btn = $(this), oldValue = btn.closest('.number-spinner').find('input').val().trim(), newVal = 0; if (btn.attr('data-dir') == 'up') { newVal = parseInt(oldValue) + 1; } else if (btn.attr('data-dir') == 'upup') { newVal = parseInt(oldValue) + 5; } else if (btn.attr('data-dir') == 'upupup') { newVal = parseInt(oldValue) + 10; } else if (btn.attr('data-dir') == 'dwn') { if (oldValue > 1) { newVal = parseInt(oldValue) - 1; } else { newVal = 0; } } else if (btn.attr('data-dir') == 'dwndwn') { if (oldValue > 5) { newVal = parseInt(oldValue) - 5; } else { newVal = 0; } } else if (btn.attr('data-dir') == 'dwndwndwn') { if (oldValue > 10) { newVal = parseInt(oldValue) - 10; } else { newVal = 0; } } else { if (oldValue > 1) { newVal = parseInt(oldValue) - 1; } else { newVal = 0; } } //if (btn.attr('data-dir') == 'up') { // newVal = parseInt(oldValue) + 1; //} else { // if (oldValue > 1) { // newVal = parseInt(oldValue) - 1; // } else { // newVal = 0; // } //} btn.closest('.number-spinner').find('input').val(newVal); }); </script>
URL-Formula Field:
"https://website.quickbase.com/db/bnhwf73ut?a=dbpage&pageID=10"
------------------------------
BlakeE
------------------------------