Revision 1ccc89c8
Von Bernd Bleßmann vor mehr als 6 Jahren hinzugefügt
bin/mozilla/io.pl | ||
---|---|---|
319 | 319 |
my $qty_dec = ($form->{"qty_$i"} =~ /\.(\d+)/) ? length $1 : 2; |
320 | 320 |
|
321 | 321 |
$column_data{qty} = $cgi->textfield(-name => "qty_$i", -size => 5, -class => "numeric", -value => $form->format_amount(\%myconfig, $form->{"qty_$i"}, $qty_dec)); |
322 |
$column_data{qty} .= $cgi->button(-onclick => "calculate_qty_selection_window('qty_$i', 'formel_$i')", -value => $locale->text('*/')) |
|
322 |
$column_data{qty} .= $cgi->button(-onclick => "calculate_qty_selection_window('qty_$i', '', 'formel_$i')", -value => $locale->text('*/'))
|
|
323 | 323 |
. $cgi->hidden(-name => "formel_$i", -value => $form->{"formel_$i"}) |
324 | 324 |
if $form->{"formel_$i"}; |
325 | 325 |
|
js/calculate_qty.js | ||
---|---|---|
1 |
function calculate_qty_selection_window(input_name, formel) {
|
|
1 |
function calculate_qty_selection_window(input_name, input_id, formel_name, formel_id) {
|
|
2 | 2 |
var parm = centerParms(600,500) + ",width=600,height=500,status=yes,scrollbars=yes"; |
3 | 3 |
var action = "calculate_qty"; |
4 |
if (formel_id) { |
|
5 |
var formel = $('#' + formel_id).val(); |
|
6 |
} else { |
|
7 |
var formel = $('[name="' + formel_name + '"]').val(); |
|
8 |
} |
|
4 | 9 |
url = "common.pl?" + |
5 | 10 |
"INPUT_ENCODING=UTF-8&" + |
6 | 11 |
"action=" + action + "&" + |
7 | 12 |
"input_name=" + encodeURIComponent(input_name) + "&" + |
8 |
"formel=" + encodeURIComponent(document.getElementsByName(formel)[0].value) |
|
13 |
"input_id=" + encodeURIComponent(input_id) + "&" + |
|
14 |
"formel=" + encodeURIComponent(formel); |
|
9 | 15 |
//alert(url); |
10 | 16 |
window.open(url, "_new_generic", parm); |
11 | 17 |
} |
templates/webpages/generic/calculate_qty.html | ||
---|---|---|
5 | 5 |
<form name="Form"> |
6 | 6 |
|
7 | 7 |
<input type="hidden" name="input_name" value="[% HTML.escape(input_name) %]"> |
8 |
<input type="hidden" name="input_id" value="[% HTML.escape(input_id) %]"> |
|
8 | 9 |
|
9 | 10 |
<table width="100%"> |
10 | 11 |
<tr><td>[% 'Please insert object dimensions below.' | $T8 %]</td></tr> |
... | ... | |
40 | 41 |
[%- END %] |
41 | 42 |
var result = [% formel %]; |
42 | 43 |
result = number_format(result, 2, '[% MYCONFIG.numberformat %]'); |
43 |
window.opener.document.getElementsByName(document.Form.input_name.value)[0].value = result; |
|
44 |
if (document.Form.input_id.value) { |
|
45 |
window.opener.document.getElementById(document.Form.input_id.value).value = result; |
|
46 |
} else { |
|
47 |
window.opener.document.getElementsByName(document.Form.input_name.value)[0].value = result; |
|
48 |
} |
|
44 | 49 |
self.close(); |
45 | 50 |
} |
46 | 51 |
|
Auch abrufbar als: Unified diff
calculate_qty (Formel): Input- und Formel-Feld auch als Dom-Id übergeben können