From 1ccc89c81f95c77ec583c973dec38b56177c81ab Mon Sep 17 00:00:00 2001 From: =?utf8?q?Bernd=20Ble=C3=9Fmann?= Date: Wed, 9 May 2018 14:21:45 +0200 Subject: [PATCH] =?utf8?q?calculate=5Fqty=20(Formel):=20Input-=20und=20For?= =?utf8?q?mel-Feld=20auch=20als=20Dom-Id=20=C3=BCbergeben=20k=C3=B6nnen?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- bin/mozilla/io.pl | 2 +- js/calculate_qty.js | 10 ++++++++-- templates/webpages/generic/calculate_qty.html | 7 ++++++- 3 files changed, 15 insertions(+), 4 deletions(-) diff --git a/bin/mozilla/io.pl b/bin/mozilla/io.pl index 7cdc751bd..fa6300482 100644 --- a/bin/mozilla/io.pl +++ b/bin/mozilla/io.pl @@ -319,7 +319,7 @@ sub display_row { my $qty_dec = ($form->{"qty_$i"} =~ /\.(\d+)/) ? length $1 : 2; $column_data{qty} = $cgi->textfield(-name => "qty_$i", -size => 5, -class => "numeric", -value => $form->format_amount(\%myconfig, $form->{"qty_$i"}, $qty_dec)); - $column_data{qty} .= $cgi->button(-onclick => "calculate_qty_selection_window('qty_$i', 'formel_$i')", -value => $locale->text('*/')) + $column_data{qty} .= $cgi->button(-onclick => "calculate_qty_selection_window('qty_$i', '', 'formel_$i')", -value => $locale->text('*/')) . $cgi->hidden(-name => "formel_$i", -value => $form->{"formel_$i"}) if $form->{"formel_$i"}; diff --git a/js/calculate_qty.js b/js/calculate_qty.js index e0aecc431..01fa5bfe5 100644 --- a/js/calculate_qty.js +++ b/js/calculate_qty.js @@ -1,11 +1,17 @@ -function calculate_qty_selection_window(input_name, formel) { +function calculate_qty_selection_window(input_name, input_id, formel_name, formel_id) { var parm = centerParms(600,500) + ",width=600,height=500,status=yes,scrollbars=yes"; var action = "calculate_qty"; + if (formel_id) { + var formel = $('#' + formel_id).val(); + } else { + var formel = $('[name="' + formel_name + '"]').val(); + } url = "common.pl?" + "INPUT_ENCODING=UTF-8&" + "action=" + action + "&" + "input_name=" + encodeURIComponent(input_name) + "&" + - "formel=" + encodeURIComponent(document.getElementsByName(formel)[0].value) + "input_id=" + encodeURIComponent(input_id) + "&" + + "formel=" + encodeURIComponent(formel); //alert(url); window.open(url, "_new_generic", parm); } diff --git a/templates/webpages/generic/calculate_qty.html b/templates/webpages/generic/calculate_qty.html index 49c105483..3d2910cbe 100644 --- a/templates/webpages/generic/calculate_qty.html +++ b/templates/webpages/generic/calculate_qty.html @@ -5,6 +5,7 @@
+ @@ -40,7 +41,11 @@ [%- END %] var result = [% formel %]; result = number_format(result, 2, '[% MYCONFIG.numberformat %]'); - window.opener.document.getElementsByName(document.Form.input_name.value)[0].value = result; + if (document.Form.input_id.value) { + window.opener.document.getElementById(document.Form.input_id.value).value = result; + } else { + window.opener.document.getElementsByName(document.Form.input_name.value)[0].value = result; + } self.close(); } -- 2.20.1
[% 'Please insert object dimensions below.' | $T8 %]