how to make a submit button redirect to another website when submiting? - submit

I have a HTML page. I have a submit button on the page. When user clicks the button, I want to redirect him to another site. Where should I put the code? Please be specific.
Thanks for advance !

Try something like
<form action="http://myRedirectedSite.com/redirectedPage.html" method="get">
<input type="submit" value="Submit">
</form>
You could use either get or post as the method depending on the other site. Note that any form field values will be passed to the other site.

Related

How rewrite URL?

I'm making a single web app.
I have a form with a POST method and an action value equal to "/login".
<form action="/login" method="POST">
<label for="mail">Email</label><input name="log" id="mail" type="text">
<label for="pass">Pass</label><input name="pass" id="pass" type="text">
<input type="submit">
When the submit button is press, server get the form, then return to the index page.
But, in the address bar, I have "local:5050/login" and would have "local:5050".
Can I remove the "login" mention ?
Since you are making a SPA, you will not want to have the POST method of the form actually complete. Generally this is done in dart by attaching a listener on the form element, within that listener you would then do a couple of things:
1) Cancel the default action (Also see: How do I prevent an on.submit event from changing/reloading the page?)
2) Get the values you're interested in from the form (or potentially take the entire form itself)
3) Send the values via an AJAX request to the server and listen for the response from the server to verify it was valid etc.
See the Dart tutorials on forms for more information on accomplishing the other steps.

Submit form directly from the controller

I have simple paypal form to submit and make a payment inside in paypal. Once I saved user data, I want to initiate form submit action.
Here is a half solution - it posts data, but doesn't bring user on paypal checkout window as html form would do.
Submitting POST data from the controller in rails to another website
HTML form:
<form action="https://www.paypal.com/cgi-bin/webscr" method="post">
<INPUT TYPE="hidden" NAME="return" value="http://back">
<input type="hidden" name="cmd" value="_cart">
...
<input type="submit" >
</form>
So I need initiate submit button click from the controller with taking user to the same page where data has been posted, same as HTML form basically does.
Well, here's a link to a related question. To be short - you can't make a redirect + POST request in HTTP.

Clarifying POST-ing to a site

Say I were to post to a site using www.mysite.com?user=myuser does that simulate the submit button that is associated with that form? If so, what happens if there are a number of submit buttons in the form?
Also, if that button's html is like so <input name="button" class="button" type="button" value="Save" onclick="javascript: submit()" disabled> with the "disabled" attribute, does that mean I can't POST www.mysite.com?user=myuser/won't work?
<form name="Form" method="post" action="/thisAction.do">
<input type="text" name="inquiryNo" maxlength="11" value="" onkeyup="javascript: checkNo()">
<input name="buttonInquire" class="button" value="Inquire" onclick="javascript: submitInquire()" type="button">
<!--Then comes a number of other inputs-->
<input.../>
<input.../>
<input.../>
<input name="modify" class="button" type="button" value="Save"
onclick="javascript: submitModify()" disabled>
</form>
This is some sample code as it's work stuff which I am not allowed to share. So when I use the inquire action a new account successfully loads up and the details are presented on the page. The modify action is meant to 'modify' those details but it just returns the same details displayed on the page. I get no sort of feedback from anything.
You can POST to a URL with a query string (the stuff after the ?), and since you say you're using urllib2 with a data argument, that's what happens. The server can then read both the POST data and the query string and do whatever it wants, though most of the time they're merged together or the query string is ignored entirely.
disabled only stops you from clicking the button in the browser (and even then, you can just un-disable it with a tool like Firebug). You can POST whatever you want to any URL you want; HTML can't stop you, though the server can still give you an error if it wants.
I think your problem is that "inquire" is the default action, and something's wrong with your POST. So no matter what you send, the server isn't recognizing it and is falling back to "inquire".
It looks like the form is intended to send modify=Save. Can you post the Python code you're actually running?
No, what you actually typed in is a GET method.
There are 2 ways of submitting data: POST AND GET.
Post is by submitting data by using a form in a webpage that posts to another on the background, while GET is setting the data in the url itself like user=myuser.
Most of the times using a GET method (url query string) will not work if the web programmer actually is checking for a POST method. The same happens if the programmer is waiting for a GET request and you actually POST it.
However there is a php var called REQUEST which will work with GET and POST.
I'm no professional in PHP but because you had no answers at the moment I tried my best to explain it. Hopefully some expert will come along and explain it properly.
You edited your question while I was replying so you need someone to answer you on your second question.

double display of jquery mobile submit buttons

I need help to rectify the following issue on some of my jQuery submit buttons. A single submit button displays two buttons with one on top of the other.
(source: nyumbanipap.com)
Any help will be appreciated.
html:
<input type="submit" name="confirmpayment" value="Confirm Payment" data-theme="a" />
It is a normal submit button on a form.
EDIT
I have noticed that this happens when returning from a non-ajax page. e.g. I am using PayPal and when I am redirected back from Paypal, this when the buttons are double displayed.
Any help will appreciated.
I just had the same problem. Turned out that I included the jquery mobile js file twice. Maybe that helps someone.
I was having the same issue within a rails app with jQuery mobile (in which I'm not always using AJAX either). Adding data-role="none" to the submit tag on the form worked for me.
<input type="submit" value="Next Question" class="ui-btn ui-state-disabled btn" data-role="none">
Go to bottom to read about that:
http://demos.jquerymobile.com/1.0/docs/forms/docs-forms.html
I know this is old but do not use the tags.
it should look like this
< p >< a href="#whatever you are naming your form or submit area" DATA-ROLE="button">Submit< /a>< /p>

asp.net mvc post to different views in same form

I have form area in my view. If I click button A, I want to submit to /Books/1 and if I click button B, I want to submit to /Books/2
How do I achieve this with MVC?
<form id="form1" name="form1" action="/Books/" method="get">
<input type="text" name="search" value="">
<input type="submit" name="id" value="1">
<input type="submit" name="id" value="2">
</form>
It sounds like what you want to do is call the Books Controller, with, say, the Search action. So for instance you might want to call /Books/Search/<search expression>/1, or /Books/Search/<search expression>/2, etc. (There's a few different ways you could be formatting these URLs, but it's mostly a matter of personal preference I think) If you want the URLs to appear as you've got them above (without the action in the URL), that can be accomplished with routing, something like this:
routes.MapRoute(
"Books",
"Books/{searchExpr}/{pageId}",
new { controller = "Books", action = "Search", searchExpr = "", pageId = 1 }
);
I think the main problem is that you're trying to use the WebForms PostBack everything paradigm in a situation where you're probably better off sending the information to the server in the URL or query string. The only time you're actually going to be posting form data here is when the user actually types something into the search box and clicks the Search button - at that point, the controller will pass the search expression to the appropriate View by stuffing it in ViewData, and from there, the View can pull it out and repopulate that textbox on the results page.
MVC Views can have multiple forms on a 'page', so just create separate sections and give each one their own form action.
<form id="form1" name="form1" action="/Books/1" method="get">
<!--...form fields-->
</form>
<form id="form2" name="form2" action="/Books/2" method="get">
<!--...form fields-->
</form>
I have never seen the ability to have a form field attached to two forms, seems like it wouldn't work. What you can do is put a hidden field in the second form which, on submission, grabs the information from the textbox in the first form.

Resources