Form does not send data to e-mail - android

I'm trying to send the data of this form to my e-mail, but nothing happens. How can I fix it? I'm new at this programming language and I would love some guidance!
<title>Solicitud de Vendedor Honorario</title>
<form action="mailto:erocha#newenergypr.com" method="post">
<table>
<tr><td colspan="2" align="center" bgcolor="#FF8000"><h2>Solicitud de Vendedor Honorario</h2></td></tr>
<tr><td colspan="2" align="center" bgcolor="#D4D4D4">Adiestramiento</td></tr>
<tr>
<td colspan="2" align="center" bgcolor="#1B4F72">
<select name="yesno" id="yesno" size="1">
<option value="yes">Yes</option>
<option value="no">No</option>
</select>
</td>
</tr>
<tr><td bgcolor="#D4D4D4">Nombre:</td>
<td><input type="text" id="nombre" size="14"></td></tr>
...
<tr><td colspan="3" align="center" bgcolor="#FF8000"><h2>Disponibilidad de tiempo</h2></td></tr>
<tr><td align="center" bgcolor="#D4D4D4"><b>Domingo</b></td>
<td bgcolor="#D4D4D4"><b>Desde:</b><select id="domingodesde" size="1">
<option value="0">No disponible</option>
<option value="00">00:00am</option>
<option value="01">01:00am</option>
<option value="02">02:00am</option>
...
More of those, exactly the same but for the other weekdays... Now checkboxes:
<tr>
<td align="center" bgcolor="#F1C40F"><b>Ponce</b></td>
<td bgcolor="#D4D4D4">
<input type="checkbox" id="arr" value="arroyo">Arroyo<br>
<input type="checkbox" id="coa" value="coamo">Coamo<br>
<tr><td colspan="2" align="center"><input type="submit" value="Submit"></td></tr>
The app looks like this:
http://imgur.com/2hiUPKw
http://imgur.com/LEEjryD
Once submited, all the data that was selected should be sent to an e-mail.

EDIT: I see now that the info you are trying to receive is from a webview. If so you can retrieve the info from your webview as such. Found here. After which you will have to parse content from the string.
webView.evaluateJavascript("(function(){return window.document.body.outerHTML})();",
new ValueCallback<String>() {
#Override
public void onReceiveValue(String html) {
}
});

Related

Want to get href and title from the table using Jsoup

I want to parse Html table using Jsoup but I am having trouble getting my requried data from it. I want to get href and title from each row of this table but I am getting the whole data from the table.
<table class="FullWidth gv" cellspacing="0" rules="all" border="1" id="ctl00_Body_STUDENT_SSS_ctrl0_COURSE_REGISTRATION" style="border-collapse:collapse;">
<tr>
<th scope="col">S#</th>
<th scope="col">Code</th>
<th scope="col">Registered Course Title</th>
<th scope="col">Credits</th>
<th scope="col">Offered Course Title</th>
<th scope="col">Class</th>
<th scope="col">Teacher</th>
<th scope="col">Fee</th>
<th scope="col"> </th>
</tr>
<tr>
<td class="Center">
1</td>
<td class="NoWrap">GSC 220</td>
<td class="Width33">Complex Variables & Transforms</td>
<td class="Center">3</td>
<td class="Width33">Complex Variables & Transforms</td>
<td class="NoWrap">BCE-4 (A) MORNING</td>
<td class="Width33">AMMAR AJMAL</td>
<td>YES</td>
<td>
<a title="Complex Variables & Transforms" class="a" href="Attendance.aspx?COID=21480" target="_blank">Attendance</a>
</td>
</tr>
<tr class="Alternating">
<td class="Center">
2</td>
<td class="NoWrap">CSC 221</td>
<td class="Width33">Data Structure and Algorithm</td>
<td class="Center">3</td>
<td class="Width33">Data Structure and Algorithm</td>
<td class="NoWrap">BCE-4 (A) MORNING</td>
<td class="Width33">ABU BAKAR</td>
<td>YES</td>
<td>
<a title="Data Structure and Algorithm" class="a" href="Attendance.aspx?COID=21478" target="_blank">Attendance</a>
</td>
</tr>
<tr>
<td class="Center">
3</td>
<td class="NoWrap">CSL 221</td>
<td class="Width33">Data Structures and Algorithm Lab</td>
<td class="Center">1</td>
<td class="Width33">Data Structures and Algorithm Lab</td>
<td class="NoWrap">BCE-4 (A) MORNING</td>
<td class="Width33">ABU BAKAR</td>
<td>YES</td>
<td>
<a title="Data Structures and Algorithm Lab" class="a" href="Attendance.aspx?COID=21479" target="_blank">Attendance</a>
</td>
</tr>
<tr class="Alternating">
<td class="Center">
4</td>
<td class="NoWrap">CSC 220</td>
<td class="Width33">Database Management System</td>
<td class="Center">3</td>
<td class="Width33">Database Management System</td>
<td class="NoWrap">BCE-4 (A) MORNING</td>
<td class="Width33">BUSHRA SABIR</td>
<td>YES</td>
<td>
<a title="Database Management System" class="a" href="Attendance.aspx?COID=21481" target="_blank">Attendance</a>
</td>
</tr>
<tr>
<td class="Center">
5</td>
<td class="NoWrap">CSL 220</td>
<td class="Width33">Database Management System Lab</td>
<td class="Center">1</td>
<td class="Width33">Database Management System Lab</td>
<td class="NoWrap">BCE-4 (A) MORNING</td>
<td class="Width33">BUSHRA SABIR</td>
<td>YES</td>
<td>
<a title="Database Management System Lab" class="a" href="Attendance.aspx?COID=21482" target="_blank">Attendance</a>
</td>
</tr>
<tr class="Alternating">
<td class="Center">
6</td>
<td class="NoWrap">CSC 320</td>
<td class="Width33">Operating System</td>
<td class="Center">3</td>
<td class="Width33">Operating System</td>
<td class="NoWrap">BCE-4 (A) MORNING</td>
<td class="Width33">BUSHRA SABIR</td>
<td>YES</td>
<td>
<a title="Operating System" class="a" href="Attendance.aspx?COID=21474" target="_blank">Attendance</a>
</td>
</tr>
<tr>
<td class="Center">
7</td>
<td class="NoWrap">CSL 320</td>
<td class="Width33">Operating System Lab</td>
<td class="Center">1</td>
<td class="Width33">Operating System Lab</td>
<td class="NoWrap">BCE-4 (A) MORNING</td>
<td class="Width33">BUSHRA SABIR</td>
<td>YES</td>
<td>
<a title="Operating System Lab" class="a" href="Attendance.aspx?COID=21475" target="_blank">Attendance</a>
</td>
</tr>
<tr class="gvFooter">
<td> </td>
<td> </td>
<td> </td>
<td class="Center">15</td>
<td> </td>
<td> </td>
<td> </td>
<td> </td>
<td> </td>
I am trying like this
Document doce = Jsoup.connect(urlofthewebsite)
.cookies(hashMap)
.get();
Element tableheader = doce.select("table[id=ctl00_Body_STUDENT_SSS_ctrl0_COURSE_REGISTRATION}").first();
for(Element element : tableheader.children())
{
System.out.println(element.text());
}
First of all, your example have typo at
select("table[id=ctl00_Body_STUDENT_SSS_ctrl0_COURSE_REGISTRATION}")
since you are ending attribute selector with } instead of ].
You avoid such errors with id start using #identifier instead of [id=identifier] and .className instead of [class=className].
Also by calling
.select("table[id=ctl00_Body_STUDENT_SSS_ctrl0_COURSE_REGISTRATION]")
.first();
you are not getting first row from table (like headers), but first table with this id (since such elements - tables with specific id - your selector suppose to find).
If you want find headers simply pick them by selecting th tags like
Element table = doce.select("table#ctl00_Body_STUDENT_SSS_ctrl0_COURSE_REGISTRATION").first();
for(Element column : table.select("th")) {
System.out.println(column.text());
}
Now based on
I want to get href and title from each row of this table but I am getting the whole data from the table.
you may want to use something like
for (Element link : table.select("a")){
System.out.println(link.attr("title")+" -> "+link.attr("href"));
//you can also use abs:href to get absolute path
}

How to login by filling a form in a website using Android

I'm trying to log on to a website that has a form to which you should provide user-name and password, check a box, and press a login button. I tried all kinds of httpClient POST messages, but it seems that it is not working. Can anyone assist and point to an example of skeleton of android Java way to login? Here is the form from the html page:
<form name="loginForm" method="post" action="/login.do">
<table border="0" cellspacing="0" cellpadding="0">
<tr>
<td width="10px"> </td>
<td><label class="formLabel" for="loginID">Username</label></td>
</tr>
<tr>
<td> </td>
<td><input type="text" name="username" value="" class="formTextField"></td>
</tr>
<tr>
<td> </td>
<td><label class="formLabel" for="password"> Password</label></td>
</tr>
<tr>
<td> </td>
<td><input type="password" name="password" value="" class="formTextField"></td>
</tr>
<tr>
<td> </td>
<td> </td>
</tr>
<tr>
<td> </td>
<td><input type="checkbox" name="agreement" value="on" class="formTextField">
I agree with <div>
<b>Terms and Conditions</b></div>
</td>
</tr>
</table>
<p><input type="submit" value="Login" class="FPFormFieldB"></p>
<p>Have you forgotten the password?</p>
<p>New user registration</p>
</form>
I managed to login using JSOUP.
The key is that you need to do a get first, then a post, with the cokies (that includes SessionID and other stuff).
Here is the code that worked for me, hopefully it will assist others:
import android.provider.DocumentsContract;
import org.jsoup.Jsoup;
import org.jsoup.Connection;
import org.jsoup.nodes.Document;
import org.jsoup.select.Elements;
public class Webbing {
public static void Open() throws Exception {
Connection.Response loginForm = Jsoup.connect("http://your website")
.method(Connection.Method.GET)
.execute();
Document document = Jsoup.connect("http://your website")
.data("username", "XXX")
.data("password", "YYY")
.data("agreement", "on")
.timeout(5000)
.cookies(loginForm.cookies())
.post();
String url = "http://a page you want to load after login";
Document fpl = Jsoup.connect(url)
.timeout(5000)
.cookies(loginForm.cookies())
.get();
body = fpl.body().toString();
ExtFile.write(body);
}
}

Html onclick firing twice in Android

Code:
function hello(){alert("Hi");};
<center>
<table border="0" height="100%">
<tbody>
<tr>
<td align="center" width="100%">
<img src="cover.png"
width="300" height="300" id="image"></img></td>
</tr>
<tr>
<td height="100%"> </td>
</tr>
<tr>
<td align="center">
<form onsubmit="go();return false">
<input class="answer" id="answer" name="answer"
onclick="hello();"/>
</form>
</td>
</tr>
<tr>
</tr>
</tbody>
</table>
</center>
I have been trying to capture when the answer text box is clicked in HTML. It works perfectly in Firefox and Chrome (I only get one Hi alert), but the onclick method fires twice when I try to run the code in a web-view in android (I get two Hi alerts). However, when I call the same function later it works properly, firing only one Hi alert.
<div style="bottom: 0; right: 0; position:absolute; margin-right:5%">
<a><img alt="" src="start.png" id="submit" onclick="go();hello();"></a>
</div>
I'm guessing it has something to do with the fact that I'm calling the function from inside the form and it's somehow firing the event twice but I have no idea how to fix it. Any help?
You could try using one() as follows.
$('#answer').one('click', function() {
alert("Hi");
});
<form onsubmit="go();return false">
<input class="answer" id="answer" name="answer"/>
</form>

where put html form in Res folder and how to show this html form in webview

I have html form.but i dont understand where is put this html form. how to display form in web view.Thanks in advance
<Html>
<Head>
<Title>
<Title>
</head>
<body>
<table width="60%" align="center">
<TR><TD colspan="2"><span class="style1">Post comments</span></TD>
</TR>
<form action="http://www.indianexpress.com/ajax/saveComment.php" id="frmcommentmain" name="frmcommentmain" method="post">
<input type="hidden" value="918703" name="storyId">
<input type="hidden" value="172.16.24.10" name="ip_addr">
<input type="hidden" value="0" name="parentcmtId">
<TR><TD height="35">Name:</TD><TD><input type="text" name="name" tiptitle="Please enter your name">
*</TD>
</TR>
<TR><TD>Email:</TD><TD><input type="text" name="email" tiptitle="Please enter your email">
*</TD>
</TR>
<TR><TD>Title:</TD><TD><input type="text" name="subject" tiptitle="Please enter subject">
*</TD>
</TR>
<TR><TD>Comment:</TD><TD><textarea title="Please enter your comments" rows="6" name="comment"></textarea>
*</TD>
</TR>
<TR><TD colspan="2"><input type="checkbox" value="checkbox" name="checkbox">I agree to the terms of use.</TD></TR>
<TR>
<TD colspan="2"> </TD>
</TR>
<TR>
<TD colspan="2"> </TD>
</TR>
<TR><TD colspan="2"><input type="Submit" name="submit" value="submit"></TD></TR>
</form>
</table>
</body>
</html>
I have read many articles but I did not get answer for putting html form.Many articles described load data from url in webview but i want to load form in webview.
Indeed place your html page in the assets folder.
For showing the webpage use a WebView
WebView wv = (WebView)findViewById(R.id.webview);
wv.loadUrl("file:///android_asset/index.html");
I would store the HTML content in a file in the assets folder in your Android project. You should then be able to read the file from your code and load it into a Webview.

Create Table from HTML code

<table style="width: 560px; border: 2px solid #fee3cc; font-size: 1em;" rules="all" border="1" cellpadding="5" cellspacing="0">
<tbody>
<tr>
<td>
<p>Bharatiya Jana Sangh</p>
</td>
<td>
<p>1951 - 1977</p>
</td>
</tr>
<tr>
<td>
<p>Janata Party</p>
</td>
<td>
<p>1977 - 1979</p>
</td>
</tr>
<tr>
<td>
<p>Bharatiya Janata Party</p>
</td>
<td>
<p>1980</p>
</td>
</tr>
</tbody>
</table>
I have the html code of table as above, and I want to directly show a new table on layout as above table code, how I can do this
In your activity:
WebView webview = new WebView(this);
setContentView(webview);
String yourHtml = "<html><body><table>...</table></body></html>";
webview.loadData(yourHtml , "text/html", "utf-8");

Categories

Resources