Showing message based on selected answer from select field - flask

I was wondering if anyone knew how to show a message on the web page based on what is chosen in the select field. For example, in the database for the selections in the select field, each item has a id, name and finish attribute.
If orange is selected from the select drop down, I was wondering how one would go about showing the finish attribute of the orange on the page. And this is to be done without hitting submit. I use sql-alchemy for the database and Flask-WTF for the forms.

As per the comment you need to:
1) Code a Javascript event function to activate on select field change
2) Make that Javascript function call a Flask API route via Ajax which returns the database information.
3) Dynamically update your page with Javascript based on the returned values.
Personally I like Vue.js as a javascript framework. Google Flask-Ajax - I think Miguel Grinberg has some good tutorials and example code on this stuff.

Related

Oracle APEX form on table, don't reset table pagination after changing values through the form

I have a form on top of a report, and when the user updates values in the report, the form pops up, they make edits, and then click "Apply Changes". There are many rows in the report and right now I have pagination set per every 15 pages. The report is set to enable partial refreshes so the data updates right after the user clicks "Apply Changes". However, if I am on any page other than the first page of the report, it resets the pagination and brings me back to the first page. Is there a way to update the report but stay on the page I'm making the edit for? That way the user can immediately see the change they made through the form.
I was able to solve the issue by using a Dialog Closed dynamic action executing the following javascript:
window.location.reload(false);
It refreshes the browser after the user makes edits, and the pagination does not reset. This is a workaround because the Refresh dynamic action resets pagination. Again this is in APEX 5.1.3.
Which Apex version do you use? I've just tried it on apex.oracle.com which runs Apex 20 and - no problem at all. Once I edit some value in a form, branch returns me to interactive report, to exactly the same page which I left.
Check branch's Behavior - it is set to redirect to page or URL, target is page where the interactive report is; check other properties for the target. Its action should be set to "None" (offered are: clear regions, reset regions, reset pagination which might be set in your branch properties).

Django ModelChoiceField, thousands of options , not user friendly

I have a ModelChoiceField in my form:
customer = forms.ModelChoiceField(Customer.objects.all())
the problem is it renders as a drop down with hundreds of options and its difficult for users to find a customer, is there a way to overcome this???
You should use Bootstrap Select - which is a JQuery plugin that allows the searching of dropdown data by setting data-live-search="true" on the desired field.
You can also set data-size="5" which would only show the first 5 options in the immediate dropdown field, other items are accessed via scrolling.
(This will not help if the problem is the time it takes for this dropdown to load).
This is incorrect way to do what you're trying to accomplish here.
If you're displaying more than 20 or so customer then the UI would clutter and it would be hard to find the customer with ChoiceField. You'd probably want to index the data from your DB into a full text search engine such as ElasticSearch which is based on Lucene and then use AJAX to query particular customer by it's name or any unique identifier.
Needless to say here that instead of the ChoiceField, now your form will have a text field and as soon as user tries to fill in the name, the AJAX calls fetches the customers from ElasticSearch and renders the result.

Tutorial to create custom reports on Oracle APEX 5

I am new to Oracle APEX 5 and I am looking for a link or tutorial to achieve below.
Create a custom report with a parameter (date).
Go to shared components > report queries (add your sql statement with parameter. Test report with Bind Variables and works fine)
Under manage instance settings I have done the required configurations to print report in PDF
Go to share components > reports layouts (add rtf layout)
Add an item (date picker) on a page so that user can select a date.
Go to page and add date picker as an item. It works fine
Pass the date selected as a parameter to the custom report and generate output in PDF.
Under report query > session state, I have enabled include application and session information. There I selected the item I created on my page. The item name is the same name as the parameter name in my SQL script.
On my page I have also include a button that will trigger the report. The button is linked to the report by the URL.
This part fails and I am unable to get a report based on the date I selected in the date picker item.
I have done numerous research but could not find a single place where they explain how to proceed.
Any explanation, link or tutorial would be greatly appreciated.
For instance your page item which stores the date parameter is P9_DATE, you have to pass the page item P9_DATE as a parameter to redirect URL on button click as https://example.com/apex/f?P=&APP_ID.:0:&SESSION.:PRINT_REPORT=<REPORT_NAME>:::P9_DATE:&P9_DATE.

Sitecore Web Form for Marketers - create a cookie

This is a two part question.
Using Web Forms for Marketers 2.3:
Is it possible to have a cookie be created on successful submission?
Without actually exporting the ascx file, would like to keep it in Sitecore.
Second question, would it be better to have a content editor choose which item has the form or would it be better/easier to have a dropdown to pick which form is needed and then have the code determine which form to show.
Thank for any insight!!!
For the First question,
If you have Sitecore DMS, on a successful submission there is an event, and a Goal maybe you can use that, insteed of a cookie.
See https://doc.sitecore.net/sitecore%20experience%20platform/personalization/walkthrough%20personalizing%20components for using it with personalization rules the picturs are for Sitecore 8 but basically the same for Sitecore 6.5+
Programmatically you can use the Analytics API, see https://sdn.sitecore.net/upload/sitecore6/65/engagement_analytics_api_cookbook_sc65-a4.pdf for Sitecore 6. The API has changed considerably with Sitecore 7.5.
An alternative is to set the cookie on the Success page.
you can have a Success page, or a Success message in WFFM. for a message use something like this:
Thanks <script>document.cookie="formsuccess=ok";</script>

Sitecore (Web Forms for Marketers) success page

Let's imagine I've made a simple form using the Web Forms for Marketers module 2.2 (for CMS 6.4), and have set this up to use a 'success page' (server side redirect to a specified sitecore item). This works great.
Now it turns out that the thank you page needs to show certain field variables from the form which was just submitted.
"Dear x, thank you for your interest in Y".
On the success page, it seems like there is no way to retrieve the information (server-side) I need to show this information.
What would be a good way to approach this problem?
Is there a way to hook into sitecore webforms before the page is redirected to the success page (so I can pass along an orderId, for example)?
You can create a custom action which will give you access to all the forms data. From the action you can redirect the user to the appropriate place. You can find documentation on how to create a custom action in the reference guide on page 42.
Make sure your action is always after Save To Database because otherwise the data won't be saved.