Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
D
dolibarr
Manage
Activity
Members
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Container registry
Model registry
Analyze
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Software_Artifact_Infrastructure_Repository
dolibarr
Commits
d56694c1
Commit
d56694c1
authored
14 years ago
by
Regis Houssin
Browse files
Options
Downloads
Patches
Plain Diff
Test: auto fill zip and town with jquery
parent
9d145b38
No related branches found
No related tags found
No related merge requests found
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
htdocs/core/class/html.formcompany.class.php
+2
-2
2 additions, 2 deletions
htdocs/core/class/html.formcompany.class.php
htdocs/lib/ajax.lib.php
+16
-14
16 additions, 14 deletions
htdocs/lib/ajax.lib.php
with
18 additions
and
16 deletions
htdocs/core/class/html.formcompany.class.php
+
2
−
2
View file @
d56694c1
...
...
@@ -613,7 +613,7 @@ class FormCompany
function
select_zipcode
(
$selected
=
''
,
$field1
=
'zipcode'
,
$field2
=
'town'
,
$field3
=
'fk_pays'
)
{
print
ajax_autocompleter_ziptown
(
$selected
=
''
,
$field1
,
$field2
,
$field3
,
DOL_URL_ROOT
.
'/societe/ajaxziptown.php'
)
.
"
\n
"
;
print
'<input id="
search_
'
.
$field1
.
'" type="text" name="
search_
'
.
$field1
.
'" size="6" value="'
.
$selected
.
'">'
.
"
\n
"
;
print
'<input id="'
.
$field1
.
'" type="text" name="'
.
$field1
.
'" size="6" value="'
.
$selected
.
'">'
.
"
\n
"
;
}
/**
...
...
@@ -622,7 +622,7 @@ class FormCompany
function
select_town
(
$selected
=
''
,
$field1
=
'town'
,
$field2
=
'zipcode'
,
$field3
=
'fk_pays'
)
{
print
ajax_autocompleter_ziptown
(
$selected
=
''
,
$field1
,
$field2
,
$field3
,
DOL_URL_ROOT
.
'/societe/ajaxziptown.php'
)
.
"
\n
"
;
print
'<input id="
search_
'
.
$field1
.
'" type="text" name="
search_
'
.
$field1
.
'" value="'
.
$selected
.
'">'
.
"
\n
"
;
print
'<input id="'
.
$field1
.
'" type="text" name="'
.
$field1
.
'" value="'
.
$selected
.
'">'
.
"
\n
"
;
}
}
...
...
This diff is collapsed.
Click to expand it.
htdocs/lib/ajax.lib.php
+
16
−
14
View file @
d56694c1
...
...
@@ -138,26 +138,26 @@ function ajax_autocompleter_ziptown($selected='',$field1,$field2,$field3,$url,$o
{
$script
=
''
;
$script
.
=
'<input type="hidden" name="'
.
$field1
.
'" id="'
.
$field1
.
'" value="'
.
$selected
.
'" />'
;
//
$script.= '<input type="hidden" name="'.$field1.'" id="'.$field1.'" value="'.$selected.'" />';
$script
.
=
'<script type="text/javascript">'
;
$script
.
=
'jQuery(document).ready(function() {
jQuery("input#
search_
'
.
$field1
.
'").blur(function() {
//
jQuery("input#'
.
$field1
.
'").blur(function() {
//console.log(this.value.length);
if (this.value.length == 0)
{
jQuery("#'
.
$field1
.
'").val("");
jQuery("#'
.
$field2
.
'").val("");
}
});
jQuery("input#
search_
'
.
$field1
.
'").autocomplete({
//
if (this.value.length == 0)
//
{
//
jQuery("#'
.
$field1
.
'").val("");
//
jQuery("#'
.
$field2
.
'").val("");
//
}
//
});
jQuery("input#'
.
$field1
.
'").autocomplete({
source: function( request, response ) {
jQuery.get("'
.
$url
.
(
$option
?
'?'
.
$option
:
''
)
.
'", { '
.
$field1
.
': request.term }, function(data){
response( jQuery.map( data, function( item ) {
if (data.length == 1) {
jQuery("#'
.
$field1
.
'").val(item.value);
jQuery("#'
.
$field2
.
'").val(item.field2);
jQuery("#search_'
.
$field2
.
'").val(item.field2);
jQuery("
input
#'
.
$field1
.
'").val(item.value);
jQuery("
input
#'
.
$field2
.
'").val(item.field2);
//
jQuery("#search_'
.
$field2
.
'").val(item.field2);
if (item.field3 > 0) {
jQuery("#'
.
$field3
.
'").val(item.field3);
}
...
...
@@ -174,11 +174,13 @@ function ajax_autocompleter_ziptown($selected='',$field1,$field2,$field3,$url,$o
dataType: "json",
minLength: 2,
select: function( event, ui ) {
jQuery("#'
.
$field2
.
'").val(ui.item.field2);
jQuery("#search_'
.
$field2
.
'").val(ui.item.field2);
jQuery("input#'
.
$field1
.
'").val(ui.item.value);
jQuery("input#'
.
$field2
.
'").val(ui.item.field2);
//jQuery("#search_'
.
$field2
.
'").val(ui.item.field2);
if (ui.item.field3 > 0) {
jQuery("#'
.
$field3
.
'").val(ui.item.field3);
}
//alert(ui.item.field2);
}
});
});'
;
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment