I have a form that contains some fields and a recaptcha box.
I have hidden the recaptcha box. The user clicks "create profile" and a modal dialog pops up with the recaptcha box. All fine.
But, how do I submit that information? I am using Javascript to create the recaptcha HTML in the modal. I have a button called "Create Profile" that has this code attatched to the onclick:
$("#form").submit()
The form data gets submitted to the create.php page, but the recaptcha info does not. Do I have to manually pass this information via the post request to create.php?
Without the modal dialog it works fine. I can't understand what's going on.
Any ideas?
The site is www.presslike.net
Just like ryley said. The modial dialog's HTML is not located between the tags. You have two choices
Move the modal dialog inside the form
Post the data from the form and the Modal using javascript
Related
I have a simple form inside a Bootstrap modal popup. The form was working fine until I needed to add a button to perform a simple calculation based on some values entered into the form.
The button just has a jQuery click event which grabs the values from the form elements, does the calculation the writes that value into a text box. When the form is not in the modal, it works just fine. Zero errors. When the form is in the modal clicking the button closes the modal and I cannot see why.
I have stripped back the button to bare bones and even removed the jquery code in the click event handler.. it still closes the modal. I have removed the form action event (points to a .php script), but the modal still closes.
When it closes I see that the browser address bar is filled with the URL for the page with all the form values as params as the field were populated when I clicked the button.
Can anyone tell me how I can get this button to just be a trivial button I can use for this purpose and NOT close the modal?
I have removed the form action event (points to a .php script), but the modal still closes.
Removing the action attribute just sets the action to the URL of the current page. It doesn't prevent the form from being submitted.
Can anyone tell me how I can get this button to just be a trivial button I can use for this purpose and NOT close the modal?
The crappy quick way
<button type="button"> will make the button a JavaScript only button and not a submit button
The proper way
In your event handler function, capture the event object and call its preventDefault() method.
Make sure that on those occasions when the JS fails, the server does the right thing and provides a sensible response for the form submission.
The probelm is very likely that the button submits the form. Try specifying <button type="button"> or add a evt.preventDefault() in the click handler.
Can I know what is the best solution for my question. I got a data entry page with multiple input textbox inside a form on the main page. After enter and click the submit button, I want it to open the result page in a modal popup window.
Two different asp files.
1) Main.asp (Input)
2) Result.asp (get Input from Main to generate the result)
The main.asp is for data entry while the result.asp will retrieves the parameter pass by the main page for further processing and generate the result. The result.asp need to have a button to close the popup window and reset the main.asp textbox.
You can't POST a form directly into a modal window. Alternatively, you could:
Intercept the JavaScript form.onsubmit event
Manually build the querystring
Open the modal with the informed parameters and,
When the user closes it, clear the required fields on the main page.
What I'm trying to do is have a contact form, and when the user hits submit a dialog box appears asking the user to confirm yes/no, and the form should not submit until the user has selected yes, or stays on the page when selects no.
What my issue is, once the dialog box opens, the form still submits, and the dialog box is open for only a second or so.
So is it possible to stop the page from loading until after the dialog box is closed or yes is clicked?
I'm using the jQuery Impromptu plugin for the dialog box.
Don't use type="submit", just use type="button". Submit the form from your own code based on the dialog result.
I'm not familiar with the impromptu library; however, I believe that this can be done by stopping the onClick event from submitting and submitting via the callback in your go_there() method. I would try replacing the onClick method with "go_there(); return false;". This should cancel the normal submit event. Then you could add a submit statement (document.email.submit();) in the true condition of your callback before you reset the location.
I'm using codeigniter.
if I click on submit button on a form, a popup confirmation will appear.
The quantity or any thing that I put on the form must appear on the popup before I confirm or purchase it.
You can't do it with default javascript popup. I suggest you use jquery ui dialog.
I have a form which user enters data and upload a picture, when user clicks submit, the browser would go to a "confirmation page(its actually blank)", I'd rather have a pop-up confirmation message that when user clicks ok it refreshes the page.
Any ideas?
some details:
first, the user enters data in the textfields and selects a file to upload
when user clicks "submit button", a confirmation page pops up, user can click "OK" or "Cancel"
if use clicks "OK", servlet is called to handle the form data including the file user wants to upload, if form submit is successful then a "success" pop up
mine seems to go to the blank confirmation page every time, no success pop up
You would submit via ajax instead of via a form submission. After the ajax call completes, you can then do anything you want in the page (show a popup) and then go to another page.
If you set the action attribute of the form to empty e.g
<form action="">
the form will submit to the same page.
You can optionally retrieve the value in the form elements without actually submitting the form, you then process it and display your confirmation message then refresh or go to another page.