Good morning, I insert a textbox to autocomplete from database with two fields (codiceprodotto, nomeprodotto)
This code in custom code
I would add a second textbox that will display on the productname related
Thanks🙂
This code in custom code
<?php
foreach($form->data['Datacom'] as $un_codice){
if(!empty($form->data['tag']) AND stripos($un_codice['codiceprodotto'], $form->data['tag']) === false){
continue;
}
$json[] = array('id' => $un_codice['nomeprodotto'], 'text' => $un_codice['codiceprodotto']);
}
echo json_encode($json);
?>
I would add a second textbox that will display on the productname related
Thanks🙂
Hi agostinopol,
Sorry but I don't understand your question :-(
Is the autocompleter working?
Where do the productnames come from and what exactly do you want to do with them?
Bob
Sorry but I don't understand your question :-(
Is the autocompleter working?
Where do the productnames come from and what exactly do you want to do with them?
Bob
excuse for the few details
The table consists of two fields (codiceprodotto, nomeprodotto)
the first textbox displays the "codiceprodotto" with this code
the second textbox I want to see the nomeprodotto related, but do not know how to do...
ps codiceprodotto is product code and nomeprodotto is product name
The table consists of two fields (codiceprodotto, nomeprodotto)
the first textbox displays the "codiceprodotto" with this code
<?php
foreach($form->data['Datacom'] as $un_codice){
if(!empty($form->data['tag']) AND stripos($un_codice['codiceprodotto'], $form->data['tag']) === false){
continue;
}
$json[] = array('id' => $un_codice['nomeprodotto'], 'text' => $un_codice['codiceprodotto']);
}
echo json_encode($json);
?>
the second textbox I want to see the nomeprodotto related, but do not know how to do...
ps codiceprodotto is product code and nomeprodotto is product name
Hi agostinopol,
After a lot of experimentation I found that there is quite an easy way to do this. Add code like this to a Load JavaScript action in your form
Bob
PS ChronoForms isn't using the latest release of Select2 - if you need the docs, go here for the Select2 3.5.3 docs!
After a lot of experimentation I found that there is quite an easy way to do this. Add code like this to a Load JavaScript action in your form
jQuery(document).ready(function(jQ) {
jQ('#country').on("select2-selecting", function(evt) {
jQ('#text3').val(evt.choice.id);
});
});
and replace country with the id of your AutoCompleter element; and text3 with the ID of the element where you want to show the value returned as id from the Ajax event.
Bob
PS ChronoForms isn't using the latest release of Select2 - if you need the docs, go here for the Select2 3.5.3 docs!
Hi GreyHead, I have followed your instructions. In form a display it is okay (in textobox codiceprodotto witch autocompleter is display the product code and in textbox nomeprodotto is display product name). But the saving in db is not correct (in the field codiceprodotto is save nomeprodotto and the field nomeprodotto is empty).
Hi agostinopol,
Please drag a Debugger action into the On Submit event, then submit the form and post the debug results here.
Bob
Please drag a Debugger action into the On Submit event, then submit the form and post the debug results here.
Bob
I have changed a few things, I have regenerated database table and email
autocompleter
javascript
in the form I see everything correctly
in the mail and db restores my twice the product name (both in code in the name)
I would not be wrong but I think the problem lies in Autocompleter code ... there is a bit of confusion
Debug:
autocompleter
<?php
foreach($form->data['Datacom'] as $uno){
if(!empty($form->data['tag']) AND stripos($uno['codiceprodotto'], $form->data['tag']) === false){
continue;
}
$json[] = array('id' => $uno['nomeprodotto'], 'text' => $uno['codiceprodotto']);
}
echo json_encode($json);
?>
javascript
jQuery(document).ready(function(jQ) {
jQ('#codice').on("select2-selecting", function(evt) {
jQ('#nome').val(evt.choice.id);
});
});
in the form I see everything correctly
in the mail and db restores my twice the product name (both in code in the name)
I would not be wrong but I think the problem lies in Autocompleter code ... there is a bit of confusion
Debug:
Data Array
Array
(
[option] => com_chronoforms5
[view] => form
[Itemid] => 127
[chronoform] => PRATICA
[event] => submit
[codiceutente] => WebMaster
[mail] => polizzano@feelplus.it
[datapratica] => 28-06-2016
[contatto] => inserire nome e/o telefono se diverso
[codice] => DH-9000 18"45
[nome] => DH-9000 18"45
[descrizionedifetto] => ygje
[manifestazionedifetto] => yytjtej
[datigaranzia] => 0
[numeroddt] => 1234.55555
[dataddt] => 14/06/2016
[datascontrino] =>
[dichiarazione] => 1
[inviopratica] => INVIA PRATICA
[mailutente] => polizzano@feelplus.it
[id] => 57
[ip_address] => xxxxxxxx
)
Array
(
)
Errors
Array
(
)
Debug Info
Array
(
[4] => Array
(
[DB Save] => Array
(
[Queries] => Array
(
[0] => INSERT INTO `garanzia_pratiche` (`codiceutente`, `mail`, `datapratica`, `contatto`, `descrizionedifetto`, `manifestazionedifetto`, `datigaranzia`, `numeroddt`, `dataddt`, `datascontrino`, `dichiarazione`, `inviopratica`, `user_id`, `uniq_id`, `created`) values ('WebMaster', 'polizzano@feelplus.it', '28-06-2016', 'inserire nome e/o telefono se diverso', 'ygje', 'yytjtej', '0', '1234.55555', '14/06/2016', '', '1', 'INVIA PRATICA', '628', '9ea886d0cf259f33c1cf773a3523549383e37a8 e', '2016-06-28 16:03:36');
)
)
)
[9] => Array
(
[Email] => Array
(
[0] => An email with the details below was sent successfully:
[1] => To:polizzano@feelplus.it, garanzia@feelplus.it
[2] => Subject:FEELPLUS - Pratica di Assistenza
[3] => From name:FEELPLUS - Assistenza Tecnica
[4] => From email:garanzia@feelplus.it
[5] => CC:
[6] => BCC:
[7] => Reply name:
[8] => Reply email:
[9] => Attachments:
[10] => Array
(
)
[11] => Body:
<table border="1">
<tr><td>Codice Utente</td><td>WebMaster</td></tr>
<tr><td>E-Mail</td><td>polizzano@feelplus.it</td></tr>
<tr><td>Data Pratica</td><td>28-06-2016</td></tr>
<tr><td>Contatto</td><td>inserire nome e/o telefono se diverso</td></tr>
<tr><td>Codice Prodotto</td><td>DH-9000 18"45</td></tr>
<tr><td>Nome Prodotto</td><td>DH-9000 18"45</td></tr>
<tr><td>Descrizione Difetto</td><td>ygje</td></tr>
<tr><td>Come si è manifestato il difetto ?</td><td>yytjtej</td></tr>
<tr><td>Dati garanzia</td><td>0</td></tr>
<tr><td>N. DDT</td><td>1234.55555</td></tr>
<tr><td>Data DDT</td><td>14/06/2016</td></tr>
<tr><td>Data Scontrino</td><td></td></tr>
<tr><td>Scontrino</td><td></td></tr>
<tr><td>id</td><td>57</td></tr>
</table>[br /][br /]IP: xxxxxxx
)
)
)
Hi agostinopol,
Hmm yes you are getting the same value in both places. Please post a link to the form so I can take a quick look (use private tags if you like).
In my test the value returned as id was in evt.choice.id and the value returned as text in evt.choice.text so they should both be available.
Bob
Hmm yes you are getting the same value in both places. Please post a link to the form so I can take a quick look (use private tags if you like).
In my test the value returned as id was in evt.choice.id and the value returned as text in evt.choice.text so they should both be available.
Bob
This is private content
:) thanks for support
Hi agostinopol,
I don't see a codiceprodotto input in the form to test the AutoCompleter? Where is it?
Also, I suggest that you use show/hide Parent for the inputs controlled by the Dati garanzia radio buttons. That will look neater.
Bob
I don't see a codiceprodotto input in the form to test the AutoCompleter? Where is it?
Also, I suggest that you use show/hide Parent for the inputs controlled by the Dati garanzia radio buttons. That will look neater.
Bob
You've been very kind, but given the problems of my form I decided to combine the two fields (ProductCode, productname) in the product so am only searching. If you are interested to test I can make available to the old form.
This topic is locked and no more replies can be posted.