I have a simple asp form which is used to insert data into the database.It's working fine on click of submit button.But it again submits itself on press of refresh.How t stop the form from doing so?
The following might work:
Store a unique form data value (timestamp?) in a cookie or session variable and check it to prevent re-processing ..
Redirect your page to itself with a GET (see also snipplr.com/view/35515/) and check (POST versus GET) on processing the page..
Related
So essentially driver.refresh() does not submit form data for example a captcha on the page. If you refresh in a browser, a pop-up appears saying confirm form resubmission if you click continue the browser submits the form data and you don't have to solve the captcha again. Is there any way that I can automate selenium to confirm the form resubmission every driver.refresh() ?
Assuming this is an alert, which is what it appears to be, you simply add this line of code after you call for the driver to refresh.
driver.switchTo().alert().accept();
Yes, you could write a Custom driver class, which extends the selenium driver class you are using, and overwrite the refresh method(or make your own). But, that would be bad practice.
Since not all pages you automate against will have form data.
Is it possible to display the form error on a redirected page instead of a rendered page?
I have 2 forms on 1 page each submitting to their own actions. If form 1 is not valid it will skip if($form->isValid()) and go straight to render
which will then display the form errors. The 'render` for this actions only displays form 1).
The issue with this is I would like it to redirect back to the original page where I have both of the forms but still display the form errors.
I don't know any easy way to do this, so I give you an idea how this could be done the "hard" way:
Serialize the validated form using JMSSerializerBundle
Set the serialized form as flashbag message
Redirect
Check for the form in the flashbag, unserialize, show the errors of both.
I have a textarea that I first print some values coming from a request.getParameter("some_textarea_name"). The user is allowed to modify those values and then I want to get the new values and replace the old ones with the new ones so as to query the new ones and get the results from my database tables. Can I do that without redirecting the user to a new page e.g without using the <form method> and the request.getParameter()
Can I do that without redirecting the user
Yes, you can implement an ajax call that will submit the form without redirecting the user and you can do something with the response (perhaps add it to the page).
If you need help using ajax follow this tutorial, but be aware that it implements AJAX in pure javascript (its a bit more bloated / complicated). If you want to keep it simple look into jQuery ajax, and here is a tutorial too.
without using the
No, you need to use the form to be submitted, however if you use ajax you wont need to redirect the user.
I'm creating an application with two pages (Page One, Page Two) that have radio buttons on them. The values are stored in sessionStorage and displayed to the user on Page 3. However, I want a Submit button that will take those values in sessionStorage and email it to me (I was planning to use PHP to process and send the email). Can someone help point me in the right direction on how to solve this please?
If you already have a form with your submit button then you could have your javascript insert new inputs of type="hidden", one for each key/value pair. These values will then be submitted with the form so you can process them just like any other POST parameter.
I'm currently working on an application that uses ASP, and I am currently having difficulty repopulating the fields of a form after redirecting back to that form.
Basically, I have a form where a user can input data into it (Say, an admin creating a new user within the system). Upon clicking the "Submit" button on the form, it goes to a processing page (say, userproc.asp) where it does input validation and adds the user to the database.
My issue is when the input validation fails, the application needs to return the user to the Form, report the issue, and keep the form populated as it was before clicking on submit.
This is where my problem lies, as I cannot find a good way to get a form to repopulate properly upon redirecting back to it using ASP. We do not want to use Javascript either.
Any thoughts/suggestions?
Make the Action for the Form point to itself instead of to a different "processing" page.
Remove the "processing" code that performs the validation and "user creation" for the "processing" page and place it in a Class defined in a new ASP page. This page is code only (just contains this class).
Include the new Class asp file in the orginal form page. On receiving a post instantiate the class and call an "Process" method where all your original code will work.
Have the method return some indication of success. If it has succeeded now you could either redirect to a "success page" or simply include the success markup in the form page. If the processing is failed you return your original form with the addition that you can set the values for all the fields to the ones received.