how can I see the url output of submitted form? - javascript

there is a website and I want to create the link address that can automate the login process.
from the login page source code, I understood that it will submit the id, passwd values with post method in form.
but I want to know the entire 'url' address which this form submission leads to. I mean, eventually it will pass on the id, passwd values like in 'somewebpage?id=someid&passwd=somepw' right? (of course it will be processed with encodeURIComponent by the form)
this parameter included url address is what I'm looking for because I think if I know this, then I can automate the login process.
However, this address is not explicitly shown(not even for a brief moment). Is there a trick to somehow 'alert()' this url address or view it through chrome developer tools or something?
here's the login page example by the way:
<form id="login" name="login" class="login" method="post"
action="" enctype="application/x-www-form-urlencoded"
style="background-image: url(../main/image/index.gif)">
<input type="hidden" name="url" value="../main/index.cgi" />
<table class="login-form">
<tr>
<td>
<table>
<tr>
<td class="label"><label for="login_id">ID</label></td>
<td class="input">
<input type="text" id="login_id" name="id" value="" onclick="select();" maxlength="8"/>
</td>
</tr>
<tr>
<td class="label"><label for="login_passwd">Passwd</label></td>
<td class="input">
<input type="password" id="login_passwd" name="passwd" value="" onclick="select();" maxlength="8"/>
</td>
</tr>
</table>
</td>
<td>
<input type="submit" id="login_submit" value="Go" />
</td>
</tr>
<tr>
</tr>
</table>
</form>

You should be able to see the POST url in firebug net panel.

Form action attribute defines where the form will be submitted.
<form action="demo_form.asp" method="get">
The current form you have will submit to it self, meaning the current url the form is now on.
You can see the page properties from chrome developer tools network tab.

When there is no url in action the page, the form will post to itself. So all you would need to do is post the username and password to this page using the name of the input. On the server side, the username and password will be checked against the DB. To automate the post process look at the function here: https://stackoverflow.com/a/133997/3402205

Related

In Html why does clicking on regular button within form action the form

I have a webpage with three buttons, two of the buttons action the form submitting data to the server, it then sends back the appropriate page.
The third button is meant to just open a new webpage in a new tab, the current page does not need to be reloaded so this button is just a button element with some onclick() code, its is not part of an input element
The trouble is that when I click on the third button it actions the form action the form even though its not an input type, why does it do this ?
<main>
<form action="/license.process" name="process" id="process" method="post">
<label>
Please enter your license information as provided in your license email
</label>
<table>
<tr>
<td><label title="Email">Email</label></td><td><input type="text" name="licenseEmail" value="paultaylor#jthink.net" class="licenseinputfield"></td>
</tr>
<tr>
<td>
<label title="License Key 1">
License Key 1
</label>
</td>
<td>
<input type="text" name="licenseKey1" value="50302c02147f23ed809a8f2579338121a2b1594f967bb18" class="licenseinputfield">
</td>
</tr>
<tr>
<td>
<label title="License Key 2">
License Key 2
</label>
</td>
<td>
<input type="text" name="licenseKey2" value="0ff02146cd1777d7e0890e659b10218761869212d7b0d60" class="licenseinputfield">
</td>
</tr>
</table>
<input type="submit" name="cancel" value="Cancel">
<input type="submit" name="save" value="Save">
<button onclick="window.open('http://www.jthink.net/songkong/buy.jsp','_blank');">
Get License
</button>
</form>
</main>
I can make it work properly by moving this third button outside of the form. But then I get formatting problem because button is shown on next line, regardless I want to understand why having the butto within the form triggers the form.
The default type of a <button> is submit.
If you want it to be type=button then you have to say so explicitly.
You need to add the type="button" attribute to prevent the form from being submitted.
I'm not entirely sure why but came across this last week.

Javascript event redirecting to another page instead of displaying result in same page

In this piece of code there is a search bar, when I am searching something it will narrow down my search. I am using onkeyup event which call javascript function to search the required data, but after entering some text in search bar when i press enter it is redirecting to the home page instead of display the results.
CODE
<apex:actionFunction name="searchServer" action="{!runSearch}" rerender="results,debug,errors">
<apex:param name="Name" value="" />
</apex:actionFunction>
<table cellpadding="2" cellspacing="2">
<tr>
<!-- style="font-weight:bold;">Defect Name<br/> -->
<td>
<input type="text" id="Name" onkeyup="doSearch();" /> </td>
</tr>
</table>
Any help would be appreciated.
I think the form is submitted on Enter button press.
If you have <apex:form tag then try putting onsubmit="return false;" there.
<apex:form onsubmit="return false;"

How to add custom validation in AngularJS for JQuery signature plugin?

I'm trying to create an input form in Angular that collects a persons name and their signature. For the signature part, i'm using a JQuery plugin that uses a canvas for them to draw the signature. I'm new at Angular and having trouble figuring out how to tie the canvas into my form validation. When the user tries to submit the form, I want Angular to stop them if the canvas is blank (signature is missing).
To check if the canvas is blank, I can make this JQuery call which returns true or false:
$('#signature').signature('isEmpty');
The HTML I have so far is:
<form ng-controller="SignatureController" ng-submit="submit()">
<table>
<tr>
<td>
<input class="td-name" type="text" required placeholder="Enter Name Here" ng-model="drivername"><br>
NAME - Please type here
</td>
</tr>
<tr>
<td>
<div class="td-signature" type="text" id="signature">
<canvas width="1098" height="268"></canvas>
</div><br>
SIGNATURE - Please sign here
</td>
</tr>
</table>
<input type="button" ng-disabled="dataLoading" value="Clear" class="btn btn-primary" onclick="$('#signature').signature('clear');">
<input type="submit" ng-disabled="dataLoading" value="Submit" class="btn btn-primary">
</form>
What would I need to add/change to make Angular mark the canvas as being required when $('#signature').signature('isEmpty') returns true?

Call the jsp pages based on javascript if else conditions

I have a jsp form like this.
<form name="search" method="post" action="a.jsp" target="menu_page"
onSubmit="return(setSearchParameters);">
<tr>
<td class="srchtext"> Search No. :</td>
</tr>
<tr>
<td >
<input type="text" name="h_trans_code" class="password" onFocus="this.select();" size="18"></td>
</tr>
</form>
After inputting the search no and click the search button it will call a.jsp page. But Now I want to check the length of Search No & if the Search No length is equal to 14 digit, it should call the new jsp page "b.jsp" else should call "a.jsp" using javascript.

Python - clicking a javascript button

I have a button on a page that needs to be clicked for me to move on to the next page in a sequence, and I was wondering how this is possible with Python. The button seems to be the mix of an HTTP POST request and Javascript, here is the code for the button:
<FORM name="ff" action="nq2.phtml" method="post">
<INPUT type="hidden" name="target" value="-1">
<INPUT type="hidden" name="fact" value="">
<INPUT type="hidden" name="parm" value="">
<INPUT type="hidden" name="use_id" value="-1">
<INPUT type="hidden" name="nxactor" value="1">
<TD align="center" valign="top">
<DIV class="pr">
<A href="javascript:;" onClick="settarget(5); setch(ch5); return false;">
I honestly have no idea how to approach something like this and was wondering if anyone had some insight about how I would go about doing it.
To simulate the submission of a form, you can send the same POST request that your browser will send to the site once the submit button is clicked. One way to do this is use urllib.urlencode to encode the form data from a dictionary and urllib2.urlopen to send the request:
import urllib, urllib2
form_data = urllib.urlencode({'target': <value>, 'fact': <value>, ...})
urllib2.urlopen("np2.phtml", form_data)

Categories