Hi! im creating a survey system and how i save the answers and questions in database. I think the question should be included as well as the answer that needs to be saved to the database. is it possible? thanks
Forums
Creating and Saving Survey Questions
Hi kevinkart,
Yes it's possible. You can save the questions if you think they may change over time.
Otherwise you could have a column for each question named - for example - q101
Or you could save the answers to a separate table where you identify the user who responded, the question id and the answer.
You can do either of these methods - and more - in ChronoForms; the question is more one of database design depending what what you intend to do with the survey data.
Bob
Yes it's possible. You can save the questions if you think they may change over time.
Otherwise you could have a column for each question named - for example - q101
Or you could save the answers to a separate table where you identify the user who responded, the question id and the answer.
You can do either of these methods - and more - in ChronoForms; the question is more one of database design depending what what you intend to do with the survey data.
Bob
Hi Greg,
I am using Chronoform v5. I am trying to create a financial health check up calculator where user will answer few questionnaires and depending on their answers a summary will be generated saying how is it and what can be done. I have created the multi page questionaire form and it also saves the data successfully. I am facing two issues:
1)It saves data in this form: Like e.g, for Gender options are Male and female, if user selects 'Male' the value stored in database is '1' and not Male. Same for other multiple choice questionaire. What should be done to save the actual choice in the database?
2)How can i create the Dynamic summary? Like it should check for certain question's answers and based on that output dynamic summary.
http://safehandindia.com/investoplanner/index.php?option=com_content&view=article&id=4&Itemid=108 is the form link.
Thanks,
Pooja
I am using Chronoform v5. I am trying to create a financial health check up calculator where user will answer few questionnaires and depending on their answers a summary will be generated saying how is it and what can be done. I have created the multi page questionaire form and it also saves the data successfully. I am facing two issues:
1)It saves data in this form: Like e.g, for Gender options are Male and female, if user selects 'Male' the value stored in database is '1' and not Male. Same for other multiple choice questionaire. What should be done to save the actual choice in the database?
2)How can i create the Dynamic summary? Like it should check for certain question's answers and based on that output dynamic summary.
http://safehandindia.com/investoplanner/index.php?option=com_content&view=article&id=4&Itemid=108 is the form link.
Thanks,
Pooja
Hi Greg,
Thank you for the reply.
First solution is very much accurate.
Second one is not so clear. Any other example if you can provide? I will have to check the answer for certain question and accordingly output the custom text. Do I have to place this conditional code in 'Custom code' event? And where to place the custom messages?
Thanks,
Pooja
Thank you for the reply.
First solution is very much accurate.
Second one is not so clear. Any other example if you can provide? I will have to check the answer for certain question and accordingly output the custom text. Do I have to place this conditional code in 'Custom code' event? And where to place the custom messages?
Thanks,
Pooja
Hi Pooja,
You can do it all in a Custom Code action using PHP to test the answers and build the message you want to send. If you nave some examples of what you need to do that might help.
Bob
You can do it all in a Custom Code action using PHP to test the answers and build the message you want to send. If you nave some examples of what you need to do that might help.
Bob
Hi Greg,
An example will be this one http://www.theshapeofmoney.co.nz/general-resources/calculators/financial-health-check-calculator.asp
Here when you enter 'calculate' button at the bottomof the page it shows message according to the answers selected.
I want to do something like that.
Thanks,
Pooja
An example will be this one http://www.theshapeofmoney.co.nz/general-resources/calculators/financial-health-check-calculator.asp
Here when you enter 'calculate' button at the bottomof the page it shows message according to the answers selected.
I want to do something like that.
Thanks,
Pooja
Hi Pooja,
I understand that is the kind of thing that you want to do. But what is and example of the logic of your calculations / text displays.
Bob
I understand that is the kind of thing that you want to do. But what is and example of the logic of your calculations / text displays.
Bob
Below is the logic where I am first comparing individual answers of two questions and then if both are true.
if (!isset($_POST['keep_accounts_of_monthly_income_expenses']) || $_POST['keep_accounts_of_monthly_income_expenses'] == 'No')
{
echo 'Track all the expenses to avoid unnecessary spending';
}
else
{
echo 'On Track'
}
if (!isset($_POST['How_much_money_for_savings_monthly']) || $_POST['How_much_money_for_savings_monthly'] == 'No')
{
echo 'Improve on Your Montly Savings';
}
else
{
echo 'On Track'
}
if (isset($_POST[keep_accounts_of_monthly_income_expenses'] == 'Yes' && $_POST[keep_accounts_of_monthly_income_expenses'] == 'Yes'))
{
echo 'Good'
}
else
{
echo 'Needs attention'
}
Below is the logic where I am first comparing individual answers of two questions and then if both are true.
where should i place this code? and where to place the event?
if (!isset($_POST['keep_accounts_of_monthly_income_expenses']) || $_POST['keep_accounts_of_monthly_income_expenses'] == 'No')
{
echo 'Track all the expenses to avoid unnecessary spending';
}
else
{
echo 'On Track'
}
if (!isset($_POST['How_much_money_for_savings_monthly']) || $_POST['How_much_money_for_savings_monthly'] == 'No')
{
echo 'Improve on Your Montly Savings';
}
else
{
echo 'On Track'
}
if (isset($_POST[keep_accounts_of_monthly_income_expenses'] == 'Yes' && $_POST[keep_accounts_of_monthly_income_expenses'] == 'Yes'))
{
echo 'Good'
}
else
{
echo 'Needs attention'
}
where should i place this code? and where to place the event?
Hi Greg,
Should I place the whole code in custom css? And where to place this custom css?On submit?
Should I place the whole code in custom css? And where to place this custom css?On submit?
I placed the code in custom code and placed it under On submit event after db save. But it is not working. Am I doing correct.
Hi Poojah12,
Please check your PHP carefully, the lines echo 'On Track' are all missing the ; at the end.
I suggest that you use the ChronoForms $form->data[''] array values instead of $_POST - in most cases they will be the same but it's more helpful to get used to using $form->data[''] as you can then use the {input_name} syntax in emails, etc.
Bob
Please check your PHP carefully, the lines echo 'On Track' are all missing the ; at the end.
I suggest that you use the ChronoForms $form->data[''] array values instead of $_POST - in most cases they will be the same but it's more helpful to get used to using $form->data[''] as you can then use the {input_name} syntax in emails, etc.
Bob
Hi Grey,
Can you guide me whats wrong here. I tried with this code:
Placed it in custom code in 'On submit' event under db save. It shows the following error attached.
Can you guide me whats wrong here. I tried with this code:
<?php
if ( $form->data['keep_accounts_of_monthly_income_expenses'] == "No")
{
echo "Track all the expenses to avoid unnecessary spending";
}
else
{
echo "On Track";
}
if ($form->data['How_much_money_for_savings_monthly'] == "No")
{
echo "Improve on Your Montly Savings";
}
else
{
echo "On Track";
}
if (isset( $form->data['keep_accounts_of_monthly_income_expenses'] == "Yes" && $form->data['keep_accounts_of_monthly_income_expenses'] == "Yes"))
{
echo "Good";
}
else
{
echo "Needs attention";
}
?>
Placed it in custom code in 'On submit' event under db save. It shows the following error attached.
Hi Pooja,
I don't see any error messages in the images you posted. The empty Errors array just says that there were none reported.
If you echo text from a Custom Code action it will display somewhere near the top of the 'Thank You' page - are you seeing that.
Bob
I don't see any error messages in the images you posted. The empty Errors array just says that there were none reported.
If you echo text from a Custom Code action it will display somewhere near the top of the 'Thank You' page - are you seeing that.
Bob
No Greg, no custom echo message is being displayed. Thank you message is displayed. If there are no errors then it must display right.
Hi Pooja,
You have a typo in this line
Bob
PS Please find yourself a good PHP validating editor, it's not my role here to debug your PHP for you.
PPS My name isn't Greg :-(
You have a typo in this line
if (isset( $form->data['keep_accounts_of_monthly_income_expenses'] == "Yes" && $form->data['keep_accounts_of_monthly_income_expenses'] == "Yes") ) {
Bob
PS Please find yourself a good PHP validating editor, it's not my role here to debug your PHP for you.
PPS My name isn't Greg :-(
Hi Grey,
I am so sorry for calling you incorrectly. And again sorryas this is not the forum to ask coding errors. As my main doubt is solved which was how to display a custom message depending on user input. Rest I will solve. Thank you so much.
Thanks,
Pooja
I am so sorry for calling you incorrectly. And again sorryas this is not the forum to ask coding errors. As my main doubt is solved which was how to display a custom message depending on user input. Rest I will solve. Thank you so much.
Thanks,
Pooja
Hi Poojah,
I'm happy to answer questions about ChronoForms and problems that you have with it. But when it gets to custom code that is not generally useful it takes time to check and verify and that time could be better used.
Bob
I'm happy to answer questions about ChronoForms and problems that you have with it. But when it gets to custom code that is not generally useful it takes time to check and verify and that time could be better used.
Bob
Hi Greg,
I am facing a issue with Chronoforms now. I have around ten fields plus one submit button in one container. Similarly around 4 to 6 fields in other containers as it is a multi page form. I am observing that when i login i see some fields get automatically removed from the first container which has ten fields in total. First I thought may be it got have deleted by mistake. But now its third time I am noticing. Fields in other containers are fine. Is there any limit for number of fields in a container?
Thanks,
Pooja
I am facing a issue with Chronoforms now. I have around ten fields plus one submit button in one container. Similarly around 4 to 6 fields in other containers as it is a multi page form. I am observing that when i login i see some fields get automatically removed from the first container which has ten fields in total. First I thought may be it got have deleted by mistake. But now its third time I am noticing. Fields in other containers are fine. Is there any limit for number of fields in a container?
Thanks,
Pooja
Hi Pooja,
My name still isn't Greg.
There's no formal limit on the number of inputs in a container. I've seen 20 or 30, sometimes more.
Are you sure that there aren't any invalid element names - with space in them for example, that might cause a problem.
Bob
My name still isn't Greg.
There's no formal limit on the number of inputs in a container. I've seen 20 or 30, sometimes more.
Are you sure that there aren't any invalid element names - with space in them for example, that might cause a problem.
Bob
Hi Grey,
I have checked all field names. They are not having spaces. Still I am having issues. Some fields are getting deleted.
Thanks,
Pooja
I have checked all field names. They are not having spaces. Still I am having issues. Some fields are getting deleted.
Thanks,
Pooja
Hi Pooja,
Please take a Form Backup using the icon in the Forms Manager and post it here and I'll take a closer look.
Bob
Please take a Form Backup using the icon in the Forms Manager and post it here and I'll take a closer look.
Bob
Hi Grey,
Now one field got deleted in second last container and one in last container. Attaching the back up.
Thanks,
Pooja
Now one field got deleted in second last container and one in last container. Attaching the back up.
Thanks,
Pooja
This is private content
Hi Pooja,
I don't see any problems with the form but, when I save I get the same error, some inputs and all the actions are lost and I see a couple of PHP Notices.
I am wondering if it might be a problem with some of the option values including / or < . . . I haven't seen that reported as a problem before though.
I'll keep looking to see if I can work out what is happening.
Bob
I don't see any problems with the form but, when I save I get the same error, some inputs and all the actions are lost and I see a couple of PHP Notices.
I am wondering if it might be a problem with some of the option values including / or < . . . I haven't seen that reported as a problem before though.
I'll keep looking to see if I can work out what is happening.
Bob
Hi GreyHead,
I am still facing that issue where fields are getting deleted. As you said 'the option value '> or /' can be a issue but I need them as the option values as it is. There are no other substitute I can give. Please let me now if you figured out anything.
On more thing I read your http://www.chronoengine.com/forums/posts/t87667.html where the requirement is to hide/show fields based on dropdown requirement.
I have a form http://safehandindia.com/investoplanner/index.php?option=com_content&view=article&id=4&Itemid=108 where if the user selects 'Single' As his marital status three fields should hide. First and second i.e, is 'No. of Children' and 'Is Spouse is working' which is on the same first page(Container) and other field is the next page(container). I saw the code and I tried modifying it according to my requirement. It is not reflecting anything. Can you please have a look at my code. I have given proper id's for the fields.
I am still facing that issue where fields are getting deleted. As you said 'the option value '> or /' can be a issue but I need them as the option values as it is. There are no other substitute I can give. Please let me now if you figured out anything.
On more thing I read your http://www.chronoengine.com/forums/posts/t87667.html where the requirement is to hide/show fields based on dropdown requirement.
I have a form http://safehandindia.com/investoplanner/index.php?option=com_content&view=article&id=4&Itemid=108 where if the user selects 'Single' As his marital status three fields should hide. First and second i.e, is 'No. of Children' and 'Is Spouse is working' which is on the same first page(Container) and other field is the next page(container). I saw the code and I tried modifying it according to my requirement. It is not reflecting anything. Can you please have a look at my code. I have given proper id's for the fields.
<option id="Single" value="Single" data-serial='12' >
window.addEvent('domready', function() {
$('Marital_Status').addEvent('change', function() {
var opt;
opt = this.getSelected().getProperty('data-serial').toString();
if ( opt.length > 0 ) {
$('Marital_Status').value = opt;
$('No_of_Children').hide();
$('Spouse_working').hide();
$('saving_for_Children_Education').hide();
} else {
$('Marital_Status').value = '';
$('No_of_Children').show();
$('Spouse_working').show();
$('saving_for_Children_Education').hide();
}
});
});
Hi Poojah,
Please make a copy of your form and test the option values without the / < > and see if that makes ad difference.
The JavaScript you have copied is mainly written to show a serial number. It's also written using the MooTools Library, not the jQuery library used with Joomla! 3
For the first two inputs on the same page you can put the inputs into a container and show/hide the container using the Events tab in the drop-down.
For the third input on the next page I would probably show or hide that using CSS conditionally on the data from previous page.
Bob
Please make a copy of your form and test the option values without the / < > and see if that makes ad difference.
The JavaScript you have copied is mainly written to show a serial number. It's also written using the MooTools Library, not the jQuery library used with Joomla! 3
For the first two inputs on the same page you can put the inputs into a container and show/hide the container using the Events tab in the drop-down.
For the third input on the next page I would probably show or hide that using CSS conditionally on the data from previous page.
Bob
Hi GreyHead,
I did as you said. I placed the two input fields in one container with ID 'married'. And in events tab of the drop down gave the required condition. But it is not working. I have attached screenshots of it
Thanks,
Pooja
I did as you said. I placed the two input fields in one container with ID 'married'. And in events tab of the drop down gave the required condition. But it is not working. I have attached screenshots of it
Thanks,
Pooja
Hi GreyHead,
I did as you said. I placed the two input fields in one container with ID 'married'. And in events tab of the drop down gave the required condition. But it is not working. I have attached screenshots of it
Thanks,
Pooja
I did as you said. I placed the two input fields in one container with ID 'married'. And in events tab of the drop down gave the required condition. But it is not working. I have attached screenshots of it
Thanks,
Pooja
Hi Pooja,
Please post a link to the form so I can take a quick look. just the URL you get using View Form, not the article URL please.
Bob
Please post a link to the form so I can take a quick look. just the URL you get using View Form, not the article URL please.
Bob
http://safehandindia.com/investoplanner/index.php?option=com_content&view=featured&Itemid=101
Hi Poojah,
I don't see the form there . . . and I asked you to post the URL from View Forms and **not** the URL from an article.
Bob
I don't see the form there . . . and I asked you to post the URL from View Forms and **not** the URL from an article.
Bob
http://safehandindia.com/investoplanner/index.php?option=com_chronoforms5&chronoform=Financial_Health_Check_Up
Its showing 500 error in my system.
Its showing 500 error in my system.
Hi Poojah,
You can get a 500 error if the form has a loop - e.g. an Event Loop action that points to the event it is in.
Please take a Form Backup using the icon in the Forms Manager and post it here and I'll take a closer look.
Bob
You can get a 500 error if the form has a loop - e.g. an Event Loop action that points to the event it is in.
Please take a Form Backup using the icon in the Forms Manager and post it here and I'll take a closer look.
Bob
Hi poojah12,
The form appears to be working OK when I test it. It is big and you need to makes sure that max_input_vars is set high orh the ChronoForms 'safe save' is enabled to make sure it will save correctly.
I got the JavaScript working using this script in a Load JavaScript action in the on Load event before the HTML (Render form) action.
Bob
PS In your drop-downs, use the Empty Option box to set Select, not the Select=Select options you have now. Otherwise Select becomes a valid option.
The form appears to be working OK when I test it. It is big and you need to makes sure that max_input_vars is set high orh the ChronoForms 'safe save' is enabled to make sure it will save correctly.
I got the JavaScript working using this script in a Load JavaScript action in the on Load event before the HTML (Render form) action.
jQuery(document).ready(function(jQ){
jQ('#married').prop('hidden', true);
jQ('#Marital_Status').on('change', function() {
if ( jQ('#Marital_Status').val() == 'Married' ) {
jQ('#married').prop('hidden', false);
} else {
jQ('#married').prop('hidden', true);
}
});
});
The 'married' container needs to be set to Type = Div so that there is a div with that ID. You can see my test here.
Bob
PS In your drop-downs, use the Empty Option box to set Select, not the Select=Select options you have now. Otherwise Select becomes a valid option.
This topic is locked and no more replies can be posted.