jQuery UI Widgets › Forums › Form › Call python script on submit form
This topic contains 1 reply, has 2 voices, and was last updated by Hristo 3 years, 9 months ago.
-
Author
-
I have a python script that has a calculation function. The calculation function parameters are the same that is requested in the form that I created using jqxform. Once I entered all the values on the form and click submit, I want to call my python script and call the calculation function based off the values from the form. Is that possible using jqxform? What I have so far is the following:
<!DOCTYPE html> <html lang="en"> <head> <meta name="keywords" content="JavaScript Form, HTML Form, jQuery Forms widget" /> <meta name="description" content="The jqxForm widget helps you build interactive HTML JSON forms. It offers rich functionality and layout options."/> <meta name="viewport" content="width=device-width, initial-scale=1 maximum-scale=1 minimum-scale=1" /> <title id='Description'>jQuery Form Widget Component</title> <link rel="stylesheet" href="../../jqwidgets/styles/jqx.base.css" type="text/css" /> <script type="text/javascript" src="../../scripts/jquery-1.12.4.min.js"></script> <script type="text/javascript" src="../../jqwidgets/jqxcore.js"></script> <script type="text/javascript" src="../../jqwidgets/jqxbuttons.js"></script> <script type="text/javascript" src="../../jqwidgets/jqxinput.js"></script> <script type="text/javascript" src="../../jqwidgets/jqxlistbox.js"></script> <script type="text/javascript" src="../../jqwidgets/jqxscrollbar.js"></script> <script type="text/javascript" src="../../jqwidgets/jqxpanel.js"></script> <script type="text/javascript" src="../../jqwidgets/jqxdropdownlist.js"></script> <script type="text/javascript" src="../../jqwidgets/jqxform.js"></script> <script type="text/javascript" src="../../scripts/demos.js"></script> <script type="text/javascript"> $(document).ready(function () { var template = [ { bind: 'RA', type: 'text', label: 'RA', required: false, labelWidth: '80px', width: '250px' }, { bind: 'Dec', type: 'text', label: 'Dec', required: true, labelWidth: '80px', width: '250px' }, { bind: 'pm_RA', type: 'text', label: 'pm_RA', required: true, labelWidth: '80px', width: '250px' }, { bind: 'pm_Dec', type: 'text', label: 'pm_Dec', required: true, labelWidth: '80px', width: '250px' }, { bind: 'Pallax', type: 'text', label: 'Pallax', required: true, labelWidth: '80px', width: '250px' }, { bind: 'RV', type: 'text', label: 'RV', required: true, labelWidth: '80px', width: '250px' }, { type: 'blank', rowHeight: '10px' }, { columns: [ { name: 'submitButton', type: 'button', text: 'Submit', width: '90px', height: '30px', rowHeight: '40px', columnWidth: '50%', align: 'right' }, { type: 'button', text: 'Reset', width: '90px', height: '30px', rowHeight: '40px', columnWidth: '50%' } ] } ]; var sampleValue = { RA: 'John', Dec: 'Scott', pm_RA: '1st Ave SW', pm_Dec: 'N/A', Pallax: 'San Antonio', RV: 'Texas' }; var sampleForm = $('#sampleForm'); sampleForm.jqxForm({ template: template, value: sampleValue, padding: { left: 10, top: 10, right: 0, bottom: 10 } }); var btn = sampleForm.jqxForm('getComponentByName', 'submitButton'); btn.on('click', function () { // function: submit // arg1: url // arg2, optional: target, default is _blank // arg3, optional: submit method - GET or POST, default is POST sampleForm.jqxForm('submit', "/cgi/test.py"); }); }); </script> </head> <body class='default'> <div id='sampleForm' style="width: 400px; height: auto;"></div> </body> </html>
Hello robin,
I saw that you know our demo with the
Submit
option.
Unfortunately, I would like to mention that we do not have experience with Python.
But I will try to help you.
You could try to specify in the second parameter the reference to your file where you handle the query.
Please, provide us with more details, is there any error message in the console or something related to our library.Best Regards,
Hristo HristovjQWidgets team
https://www.jqwidgets.com -
AuthorPosts
You must be logged in to reply to this topic.