From 4a448ba5f96d4b966fa453794ddb28f5c8d651dc Mon Sep 17 00:00:00 2001 From: snipe Date: Fri, 5 Oct 2018 03:43:40 -0700 Subject: [PATCH] Increment tag based on first --- resources/views/hardware/edit.blade.php | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/resources/views/hardware/edit.blade.php b/resources/views/hardware/edit.blade.php index 8ba273648..f0ecc94d4 100755 --- a/resources/views/hardware/edit.blade.php +++ b/resources/views/hardware/edit.blade.php @@ -209,30 +209,36 @@ // Add another asset tag + serial combination if the plus sign is clicked $(document).ready(function() { + var max_fields = 3; //maximum input boxes allowed var wrapper = $(".input_fields_wrap"); //Fields wrapper var add_button = $(".add_field_button"); //Add button ID var x = 1; //initial text box count - var base_increment = $("#asset_tag").val(); - var incremented_tag = base_increment.replace(/[^\d]/g, ''); + $(add_button).click(function(e){ //on add input button click e.preventDefault(); + + var auto_tag = $("#asset_tag").val().replace(/[^\d]/g, ''); var box_html = ''; + // Check that we haven't exceeded the max number of asset fields if (x < max_fields) { + var auto_tag = parseInt(auto_tag) + parseInt(x); x++; //text box increment - incremented_tag++; - console.log(x); + + console.log('Auto tag: ' + auto_tag); + console.log('X: ' + x); + //console.log('Incremented: ' + parseInt(incremented_tag)); box_html += ''; box_html += '
'; box_html += '
'; - box_html += ''; + box_html += ''; box_html += '
'; box_html += '
'; box_html += '';