3 <STYLE TYPE="text/css">
4 .ui-autocomplete-loading {
5 background-color: silver;
7 ul.ui-autocomplete li.ui-menu-item {
11 ul.ui-autocomplete li.ui-state-focus {
14 background-color: inherit;
15 border: 1px solid #7e0079;
18 <SCRIPT TYPE="text/javascript">
19 $().ready(function() {
20 $('input.taxproduct_desc').autocomplete({
21 source: '<% $fsurl %>misc/taxproduct.cgi',
24 response: function( event, ui ) {
25 // if there's only one choice (user entered an exact taxproduct) then
27 if ( ui.content.length == 1 ) {
28 var input_taxproductnum = $(this).siblings('.taxproductnum')
29 var item = ui.content[0];
30 $(this).val(item.label);
31 input_taxproductnum.val(item.value);
34 focus: function( event, ui ) {
37 select: function( event, ui ) {
38 // find the hidden input for the taxproductnum
39 var input_taxproductnum = $(this).siblings('.taxproductnum')
41 $(this).val(ui.item.label);
42 input_taxproductnum.val(ui.item.value);
43 return false; // don't store item.value in this input
45 input_taxproductnum.val('');
48 change: function( event, ui ) {
49 var input_taxproductnum = $(this).siblings('.taxproductnum')
50 if ( $(this).val() == '' ) {
51 input_taxproductnum.val('');
59 <INPUT NAME = "<% $name %>"
62 VALUE = "<% $value |h %>"
63 CLASS = "taxproductnum"
65 <INPUT NAME = "<% $name %>_description"
66 ID = "<% $name %>_description"
68 VALUE = "<% $description %>"
70 CLASS = "taxproduct_desc"
72 <BUTTON STYLE="padding: 0" onclick="<% $onclick %>">...</BUTTON>
80 my $name = $opt{element_name} || $opt{field} || 'taxproductnum';
81 my $value = length($opt{curr_value}) ? $opt{curr_value} : $opt{value};
82 my $description = $opt{'taxproduct_description'};
84 unless ( $description || ! $value ) {
85 my $part_pkg_taxproduct =
86 qsearchs( 'part_pkg_taxproduct', { 'taxproductnum'=> $value } );
87 $description = $part_pkg_taxproduct->taxproduct . ' ' .
88 $part_pkg_taxproduct->description
89 if $part_pkg_taxproduct;
92 my $conf = FS::Conf->new;
93 my $vendor = lc($conf->config('tax_data_vendor'));
94 my $onclick = $opt{onclick} ||
95 "overlib( OLiframeContent('${p}/browse/part_pkg_taxproduct/$vendor.html?_type=select&id=${name}&taxproductnum='+document.getElementById('${name}').value, 1000, 400, 'tax_product_popup'), CAPTION, 'Select product', STICKY, AUTOSTATUSCAP, MIDX, 0, MIDY, 0, DRAGGABLE, CLOSECLICK); return false;";