Hello everyone,
I have a problem with a form to multiple-dropdown.
The fields are:
Province (Provincia) = input1
City (Comune) = input2
Assistance Center (CAT) = input3
Address (Indirizzo) = input4
I followed this guide to create the form.
I asked the board to Greyhead, and evaluating the situation together we noticed a problem with the code of the page.
Let me explain:
For example, if I choose as Province: Alessandria
And then choose how City: Avolasca
The page code of input3 is as follows:
I believe that the field input2 face a sort of by-pass.
The problem may be caused by the Custom Code?
This is my form.
I ask for your help.
Thank you
I have a problem with a form to multiple-dropdown.
The fields are:
Province (Provincia) = input1
City (Comune) = input2
Assistance Center (CAT) = input3
Address (Indirizzo) = input4
I followed this guide to create the form.
I asked the board to Greyhead, and evaluating the situation together we noticed a problem with the code of the page.
Let me explain:
For example, if I choose as Province: Alessandria
And then choose how City: Avolasca
The page code of input3 is as follows:
<option value="Alessandria"> (CAT) </option>
I believe that the field input2 face a sort of by-pass.
The problem may be caused by the Custom Code?
This is my form.
I ask for your help.
Thank you
I solved part of my problem, essentially the Custom Code in ajax previously was:
Now having changed is:
Therefore now the code page is correct,
Now I get this code:
But, Why the address (Indirizzo) field still does not work?
<?php
$results = array();
$results[] = '=-';
foreach ( $form->data['DATA2'] as $v ) {
$results[] = $v['Provincia'].'='.$v['Comune'];
}
$results = implode("\n", $results);
echo $results;
$mainframe =& JFactory::getApplication();
$mainframe->close();
?>
Now having changed is:
<?php
$results = array();
$results[] = '=-';
foreach ( $form->data['DATA2'] as $v ) {
$results[] = $v['Comune'].'='.$v['Comune'];
}
$results = implode("\n", $results);
echo $results;
$mainframe =& JFactory::getApplication();
$mainframe->close();
?>
Therefore now the code page is correct,
Now I get this code:
<option value="Avolasca">Avolasca</option>
But, Why the address (Indirizzo) field still does not work?
I solved it! Now it works!
I was wrong to set the DB Field in the Address field ajax event!
I was wrong to set the DB Field in the Address field ajax event!
Now I have another question though.
In this form instead of clicking the Submit button to fill the table of the desired data,
it is possible that the data will be filled in the same page?
The field that will fill the table is CAT (input3).
Click Submit to display the data that I would get.
What do I do?
In this form instead of clicking the Submit button to fill the table of the desired data,
it is possible that the data will be filled in the same page?
The field that will fill the table is CAT (input3).
Click Submit to display the data that I would get.
What do I do?
Hi napster,
I see that the answer was as I suggested two days ago,
I think that you could display the data in the current page using a custom Ajax query - similar to the dropdown queries.
Bob
I see that the answer was as I suggested two days ago,
I think that you could display the data in the current page using a custom Ajax query - similar to the dropdown queries.
Bob
Hi Greyhead,
I have another question:
Once you have chosen your data and click Update (Aggiorna) in my form,
how do I do that before the chosen data set remain even after the Upgrade?
Thanks
I have another question:
Once you have chosen your data and click Update (Aggiorna) in my form,
how do I do that before the chosen data set remain even after the Upgrade?
Thanks
Let me explain:
Now the user selects his own province,
then their city, and then your cat and then click Submit.
After the user has clicked on Submit, the data that had previously selected (City and CAT) they disappear!
After the user has clicked Submit, it is possible that the data previously chosen (City and CAT) are selected as the ones before?
Now the user selects his own province,
then their city, and then your cat and then click Submit.
After the user has clicked on Submit, the data that had previously selected (City and CAT) they disappear!
After the user has clicked Submit, it is possible that the data previously chosen (City and CAT) are selected as the ones before?
Hi Napster89,
Thank you, I understand. There's a solution for CFv4 in this post but I haven't yet seen one for CFv5.
Bob
Thank you, I understand. There's a solution for CFv4 in this post but I haven't yet seen one for CFv5.
Bob
Hi Napster89,
Thank you, I understand. There's a solution for CFv4 in this post but I haven't yet seen one for CFv5.
Bob
I have add a Load JS action in On Load event.
I have replace in the JS code the FORM NAME with 'Form_Completo' and AJAX EVENT with 'ajax'.
I have replace 'aaa' with 'input2' and 'bbb' with 'input3' of the primary and secondary drop-downs.
JS code is as follows:
<?php
if ( !$form->data['input3'] ) {
$form->data['input3'] = '';
}
$doc =& JFactory::getDocument();
$script = "
var secondary_value = '{$form->data['input3']}';
";
$doc->addScriptDeclaration($script);
?>
window.addEvent('domready', function() {
var primary, secondary;
primary = $('input2');
secondary = $('input3');
if ( primary.value ) {
var load_req = new Request({
url: 'index.php?option=com_chronoforms&chronoform=Form_Completo&format=raw&event=ajax',
method: 'get',
onRequest: function(){
secondary.empty();
new Element('option', {
'value': '',
'text': 'Loading...'
}).inject(secondary);
},
onSuccess: function(responseText){
secondary.empty();
var response_data = responseText.trim().split("\n");
response_data.each( function(line) {
var line_data = line.split("=");
var selected = ( line_data[0] == secondary_value );
new Element('option', {
'value': line_data[0],
'text': line_data[1],
'selected': selected
}).inject(secondary);
});
secondary.fireEvent('change');
},
onFailure: function(){
secondary.empty();
new Element('option', {'value': '', 'text': 'Loading failed.'}).inject(secondary);
}
});
load_req.send(primary.get('name')+'='+primary.value);
}
});
But it doesn't work...
Can you help me please?
Hi greyhead,
I have solved the second Field (Comune) with this code:
But, the field CAT if I add the new Js code in Load event isn't working!
Why?
I have solved the second Field (Comune) with this code:
<?php
if ( !$form->data['input2'] ) {
$form->data['input2'] = '';
}
$doc =& JFactory::getDocument();
$script = "
var secondary_value = '{$form->data['input2']}';
";
$doc->addScriptDeclaration($script);
?>
window.addEvent('domready', function() {
var primary, secondary;
primary = $('input1');
secondary = $('input2');
if ( primary.value ) {
var load_req = new Request({
url: 'index.php?option=com_chronoforms&chronoform=Form_Completo&format=raw&event=ajax',
method: 'get',
onRequest: function(){
secondary.empty();
new Element('option', {
'value': '',
'text': 'Loading...'
}).inject(secondary);
},
onSuccess: function(responseText){
secondary.empty();
var response_data = responseText.trim().split("\n");
response_data.each( function(line) {
var line_data = line.split("=");
var selected = ( line_data[0] == secondary_value );
new Element('option', {
'value': line_data[0],
'text': line_data[1],
'selected': selected
}).inject(secondary);
});
secondary.fireEvent('change');
},
onFailure: function(){
secondary.empty();
new Element('option', {'value': '', 'text': 'Loading failed.'}).inject(secondary);
}
});
load_req.send(primary.get('name')+'='+primary.value);
}
});
But, the field CAT if I add the new Js code in Load event isn't working!
Why?
Hi Greyhead,
I have a problem with the third field (CAT).
How can I fix it?
Thanks
I have a problem with the third field (CAT).
How can I fix it?
Thanks
Why would it work for City but not for CAT ? what are the differences between the 2 fields ?
Regards,
Max
Regards,
Max
Why would it work for City but not for CAT ? what are the differences between the 2 fields ?
Regards,
Max
I do not know in fact I'm trying to understand.
As indicated by the topic indicated by Greyhead, are in the same situation in the first post:
- The first dropdown (Provincia) (input1) takes the values directly from a database
- The second dropdown (Comune) (input2) depends on the first dropdown
- The third dropdown (CAT) (input3) depends on the second dropdown
As indicated in the last code I posted, only the second dropdown works but not the third, why?
Maybe the code I changed is wrong?
Thank you very much
Well, your latest posted code has no references to "input3", so I guess that's why it doesn't work ?
Regards,
Max
Regards,
Max
This topic is locked and no more replies can be posted.