How do I fill and submit a form remotely? - javascript

How can I fill out and submit this form remotely: http://mta-nyc.custhelp.com/cgi-bin/mta_nyc.cfg/php/enduser/ask.php
The form asks for email and then it has a pull down menu and fields for Subject and Question.
Clicking the Next button takes you to a new page and in that page you click submit.
Can I fill this form and submit with one click from my site?
I will have a form in my site where the user will fill out his email and I will have pre-populated fields for Subject and Question and when the user will click the submit button the remote form will be filled and submitted.
How can I do this (with python and javascript)?

If you are submitting the page to your python backend, check out Mechanize.

Try twill - http://twill.idyll.org/python-api.html. I't some wrapper of Mechanize.

Issue a post to ~/api/feedback with the same headers and form data that their form produces?
Open up Chrome dev tools or whatever, go to the network tab, fill out the form manually once and copy the last HTTP POST?
Depending on the type of feedback on that form, the data will change. The data I posted looks like:
feedback: {"name":{"first":"Test","last":"Test"},"email":"test#test.co","feedbackType":{"service":{"sid1":10000,"sid2":14000},"categories":{"cid1":14308}},"attributes":[{"id":"branch_line_route","value":"F"},{"id":"traincarnumber","value":"1"},{"id":"date_of_event","value":"2020-09-10T13:35:47.318Z"},{"id":"time_of_occurence","value":"15:37:37"}],"comment":"Nice train"}

Related

How to transfer (editable) form data to another (non-editable) form?

I'm trying to get customers to fill out a particular form (form1) on my website (coded in html/javascript/css etc), and I want the data from that form to auto-populate another form (form2) which is on another website without moving the user to that website. Once the user submits form1, the data should auto-populate form2 and submit it as well. I cannot change anything about form2. There are some text fields and some drop-down options. I have exactly the same input fields in form1, but I am able to edit form1.
I have tried using WordPress plugins like Miraget, and tried coding my form1 to include "post" methods that use the 'id' of the variables. However, I cannot add "get" methods to form2. I'm unsure about how to proceed with this.
I have no working code because I don't know how to approach this problem. I just have the html code for form1 and the html code for form2 (classic html forms).
Try to send the data from form1 to PHP script, that script send data to form2.
Bye

Drupal contact form validation and alert not working

I am trying to make a Drupal website. My issue is that - I am not getting any alert/notification after contact form submission.
The page redirects to the Home page. The Form is working fine as I can receive the mail for the contact form but It never shows any success/fail alert.
Moreover, If the required fields are left empty and the form is submitted, then the contact page only reload.
This happens only when I am using Venture theme.
I want alerts for required fields, success and fail notifications.
I am using Drupal 7.40.
Any help/suggestion is appreciated. Thank you

How to retain dropdown selected value after postback javascript?

I have a form in my site. Fiddle is here
I removed tag because it gives error without action.
Here my issue is when I have full form with action, if I click the form its post back the page. Meanwhile the drop down menu show select an option :
before the form is submitted
when I select
After form is submitted
But I want the form should remain the values which is selected before the form is submitted. How can I do that?
You could either have the form content dynamically generated on the server-side, and when you submit, you generate the new form with the data already in it.
Or you could resort to ajax instead and don't do form submits.
When you submit your form, it will reload the page. And when the page is reloaded, the select option is by default "select an option".
You have to store the value before submitting, and when the page is reloaded, check if there is something stored. You can do that with the localStorage for exemple.
Or the second solution is to load the content in ajax, with a webmethod.

costum redirect after submit

I have this form: http://lawb.co.il/HTMLPage.html
When someone click on the submit button ("שלח טופס" ) they are automaticaly redirected.
How can I prevent this action after clicking on the "שלח טופס" button, or that the page will redirect to a page that I choose and still I will get the information that people fill in the form?
The code is here http://jsfiddle.net/TCpkb/4/
Can you help me with it pleas?
You need to submit using AJAX and then redirect manually to your custom page. If you cannot use JavaScript, there is unfortunately no way to control the redirection if you let the user directly submit the HTML form.

javascript error form validation: all inputs fields are cleared on submitting

am using a form to register the user on my website and i have a captcha security on it. Everything is working well and good but the only problem that i am facing is that if i enter a wrong captcha or somehow the page refreshes , all the data entered by the user is wiped out.
what i wish to achieve is that even if the captcha entered is wrong and the form is submitted , the form should have all the fields intact as the user filled in excluding the captcha field.
How can this be done? My form is html and by using javascript im validating it
Some browsers may be smart enough to do this, but if you want to make sure, the only way to retain data across a page reload/refresh (including form submission) is to keep it on the server, and/or put it in a cookie.
However, instead of using a submit button, you could use a normal button with an onclick() function which validates the data first, then manually submits the form if appropriate.
document.forms["form_name"].submit()
You also have to handle key events for the form text inputs, to prevent enter from submitting.
However, this is still much easier in the end, since it prevents the page from changing and doesn't require server side storage or cookies.

Categories

Resources