Submit the another website submit button from website - javascript

I want to submit the another website submit button from my website using javascript, is it possible..? My Code are below:
<script type="text/javascript">
function formSubmit() {
document.getElementById("form1").submit();
}
</script>
<form name="form1" method="post" action="http://XXXXX/Login.aspx?ReturnUrl=%2fdefault.aspx?" id="form1" >
<input type="hidden" name="NewCorporateId" id="NewCorporateId" value="XX" />
<input type="hidden" name="UserName" id="UserName" value="XXXX" />
<input type="hidden" name="Password" id="Password" value="XXXX" />
</form>
<form name="form2" id="form2" method="post>
Click here
</form>

Specified URL opened fine in new tab and button not submitted in that
site. That site contain the one submit button and username and
password text filed.. I have username and password value.. So i try to
submit the button in referring site from my website.
Its possible and the post code is correct, but because you post on aspx page Login.aspx, aspx pages protect from sending data that is not come from the same site by adding a hash code of controls. Also there is the ViewState of the page, and other hidden parameters added by aspx - so your call will fail.
Contact with the one that handle the login.aspx page to give you some way to login there - not direct by the page.
related :
What is the purpose of __EVENTVALIDATION __VIEWSTATE in aspx?

Related

I want my html page to redirect to another html page when I submit a certain input how can i do that

strong text
I need the html page to go to another page when i submit a certain input
This can be done via HTML forms.
you need to use the action(where you want to redirect page) and method(GET,POST) attribute in form.
for example
<form action="www.example.com" method="post">
<input type="text" name="firstname">
<input type="submit" name="submit">
</form>
on clicking submit it will redirect to the URL given in the action attribute.

Redirecting to a blank page after document.forms[0].submit()

I have a simple HTML page that logs into another website by creating a form with a "POST" method and a URL as the action, along with a username and password. After "document.forms[0].submit()", I want a blank page to be displayed instead of URL. I have tried the 4 commands below after "document.forms[0].submit()", but it just momentarily redirects to "about:blank" before redirecting to the URL. The code is as follows:
<form method="POST" action="https://example.com/login">
<input type="text" name="username" value="xxx" />
<input type="password" name="password" value="xxx" />
</form>
document.forms[0].submit();
//window.location.replace("about:blank")
//location.href="about:blank";
//window.open("about:blank", "_self");
location.replace("about:blank");
Is there another way to redirect to the blank page on a more permanent basis?

i m trying to redirect one JSP page to another along with the input text value

Page1.JSP
//input text box
Enter Form id:<input type="text" name="formID" id="formID" >
Show Form
This returns a null value. In page2. JSP
//get the input value
<%String formsubmitID=request.getParameter("formID");%>
This returns null. I am not able to parse. I tried all the methods using window.location, adding a button adding a href link but i am not able to access the input text field and redirect both at the same time. Here is the code for first JSP Page from which I need to redirect to another JSP Page with the input text field entered at Firest JSP Page.
I tried using a button and redirect in Java script
//javascript for redirecting to another page
function redirect(elem){
alert("in redirect Method:")
elem.setAttribute("action","Page2.jsp");
elem.submit();
return false;
}
// Page1.JSP
<form ACTION="Page2.jsp" METHOD="POST" onload='onload()'>
Enter Form id:<input type="text" name="formID" id="formID"/>
<INPUT TYPE="SUBMIT" value="Submit" onclick="redirect(this);">
</form>
This also doesn't work. Redirect doesn't happen at all when I am using window.location.href or window.location.
Please help me find the solution for the same.
When you are using form than whenever you click on button you will be directed to Page2.jsp (i.e. url mentioned in form action) like
<form ACTION="Page2.jsp">
Enter Form id:<input type="text" name="formID" id="formID"/>
<INPUT TYPE="SUBMIT" value="Submit">
</form>
In Page2.jsp get value of text field like
<%String formsubmitID=request.getParameter("formID");%>

How get popup alert if the form send success

The form:
<form name="htmlform" action="index.html" method="post"/>
<input type="text" id="companyname" name="companyname"/>
<span id='htmlform_companyname_errorloc' class='error'></span>
<input type="contact" id="contactperson" name="contactperson"/>
<span id='htmlform_contactperson_errorloc' class='error'></span>
<input type="submit" value="Submit"/>
</form>
Validation:
<script type='text/javascript'>
// <![CDATA[
var frmvalidator= new Validator("htmlform");
frmvalidator.EnableMsgsTogether();
frmvalidator.addValidation("companyname","req","Please provide company name");
frmvalidator.addValidation("contactperson","req","Who is the contact person?");
// ]]>
</script>
How can I get a pop window if the form submitted successfully?
I think you need to redirect the user to page that has the popup screen for you
the case is:
if user submit the form
1.1.when not valid then stay in the same page
1.2.when is valid then (you can do this) go to another page / (or this) stay on the same page
you need to set variable when it successful submitted and then check it later on your view

Submit form to another page (which is different from the page used in ACTION)

I have a form like this:
index.php
<form method="post" action="send.php">
<textarea name="msg" id="msg"></textarea>
<input type="submit" value="Send" />
</form>
So, if I enter something in textarea and clicked on "Send", it is submitted to "send.php" page. But I want to include another button for previewing it. That is, when this button is clicked, the above form is submitted to "preview.php" which will be opened in a new blank window/tab (original page ie. index.php will be there intact). This is to display a preview of the message, that the user is going to send.
I do not know how to do this.
Use Javascript to temporarily change the action and target:
<form method="post" action="send.php" id="idOfForm">
<textarea name="msg" id="msg"></textarea>
<input type="submit" value="Send" />
</form>
<button onclick="doPreview();">Preview</button>
<script type="text/javascript">
function doPreview()
{
form=document.getElementById('idOfForm');
form.target='_blank';
form.action='preview.php';
form.submit();
form.action='send.php';
form.target='';
}
</script>
There is now an attribute for the submit input that handles this:
<input type="submit" formaction=”differentThanNormalAction.php”>
Give your form an ID (form1). The action of the current form can be controlled like this:
function setPreview() {
$('#form1').attr('target','_blank')
$('#form1').attr('action','http://yourpreviewurl.php')
$('#form1').submit()
}
function setSubmit() {
$('#form1').attr('target','')
$('#form1').attr('action','http://yourposturl.php')
$('#form1').submit()
}
Have two buttons, both type="button", one to call setPreview and another to call setSubmit
You can use JavaScript to change the action of the form when the button is clicked and then submit it.
Or simply submit the form via AJAX and then redirect after you get a response.
<form onreturn="someJavascriptFunction()" action="" method="">
creating a js function able to open this preview page

Categories

Resources