Hi I trying to get values from two hidden inputs. (__VIEWSTATE and __EVENTVALIDATION)
<form name="FormLogin" method="post" action="Same.aspx" id="FormLogin">
<div>
<input type="hidden" name="__OTHER" id="__OTHER" value="SOME not importent value" />
<input type="hidden" name="__VIEWSTATE" id="__VIEWSTATE" value="/someLongValuewhatIwant=" />
</div>
<div>
<input type="hidden" name="__EVENTVALIDATION" id="__EVENTVALIDATION" value="/someOtherValueWhatIwant" />
</div>
</form>
My code
doc = Jsoup.connect("http://example.com/index.aspx").get();
Elements input = doc.select("input[type=hidden]");
Element viewst = input.select("#__VIEWSTATE").get(0);
Element eventvd = input.select("#__EVENTVALIDATION]").get(0);
viewstate = viewst.val();
eventvalidation = eventvd.val();
But I always got only __VIEWSTATE value and my app crashed when i try to get __EVENTVALIDATION value. Can someone please explain me why ? and How to make it work ?
Jsoup always crashes android when the select matching expression cannot match any element in the given doc which in your case#__EVENTVALIDATION in not on your input element.
Check in your Elements input if #__EVENTVALIDATION exists.
Btw:In your code you can directly access any element by selecting #id tag. for example
doc = Jsoup.connect("http://instantgram.ic.cz/index.html").get();
Elements eventvd = doc.select("input[id =__EVENTVALIDATION");
Related
HTML 'input' tag with type file is not working in mobile. How to fix it?
Help me to fix it.
Thanks in advance.
My code follows below:
<body>
<h1><font color="white">REPORT</font></h1>
<br><br>
<form id="f1" action="summary.html">
<p>
<b><font color="white">Project Name:</font></b><br>
<input type="text" name="project" id="project" value="" required="required">
</p>
<p>
<b><font color="white">Report:</font></b><br>
<input type="file" accept="application/pdf">
</p>
<p>
<button type="button" onclick="submitData()">Submit</button>
</p>
</form>
</body>
edit 1:
My JS code as follows:
function submitData() {
var proj = document.getElementById("project").value;
if( proj == "") alert("Please enter the required field");
else document.getElementById("f1").submit();
}
I develop on Ionic framework and had the same problem.
For me, removing the accept input make things works.
I see that this have a partial support and shouldn't then be use for Hybride app.
I have try it on my mobile Chrome Browser it have no Problem look at the photo
I am working on a web app where, I have a Common popup as a direct child of , it contains few popups created dynamically from the JSON. There are two separate pages having user input form. JSON file is updated using the form data.
I am updating the contents of the popups using the updated JSON in the form submit function. I am facing the problem to refresh the popup contents on form submit. I have to restart the APP to see the changes on popups.
I tried triggering 'refresh' and 'create' events on popups in form submit function, but still no result.
Moreover even if I set the contents of popup div to be empty using $('#popup-div').empty() in submit function, I can still see the popup. Don't know if this is the caching problem.
Please advice for some solution, Thanks
Example Code:
<body>
<div id="common-popup">
<div id="data-popup" data-role="popup">';
<p>Name: N/A<p>
<p>DOB: N/A <p>
</div> <!--Popup div ends -->
</div>
<div data-role="page" id="page1">
<input type='text' id='p1_name' value=''>Name: </input>
<input type='text' id='p1_dob' value=''>DOB: </input>
<button class="update-data" id="b1"/>
Watch Data
</div>
<div data-role="page" id="page2">
<input type='text' id='p2_name'>Name: </input>
<input type='text' id='p2_dob'>DOB: </input>
<button class="update-data" id="b2"/>
Watch Data
</div>
</body>
<script type="text/javascript">
$('.update-data').on('vclick', function(){
var id = $(this).id;
id = id.split('');
var htm = '<div id="data-popup" data-role="popup">';
htm += '<p>Name: ' + $('#p' + id[1] + '_name').val() +'<p>';
htm += '<p>Name: ' + $('#p' + id[1] + '_name').val() +'<p>';
$('#common-popup').html(htm).trigger('create');
});
</script>
Here is the working demo
$( "#common-popup #data-popup")
.enhanceWithin().popup()
.on('popupafterclose', function(event) {
$(this).remove();
});
JS Fiddle Demo
The dynamic popup created should be removed after its closed. Creating it again and again makes multiple popups..but you are still referring to the first one, which created the problem.
If I have a HTML form like this:
<form action="form_action.php" method="post">
First name: <input type="text" name="fname" /><br />
Last name: <input type="text" name="lname" /><br />
<input type="submit" value="Submit" />
</form>
And then I want to fill the fname & lname then like "press" the submit button programmatically and after that show the form_action.php with the post's in a webview.
And just so you know, I can't change the form, b'cause it's not my site I'm using.
Is that possible?
Hope you get it.
Thanks in advance. (Very sorry for bad english!)
I'm making a prototype and the manipulation of the url when submitting a form is causing me issues. I just want to redirect to the link but keep my styling.
<form method = "link" action="portal.html" class="forms">
<label>Username:</label>
<input type="text" name="username" />
<label>Password:</label>
<input type="password" name="password" />
<input type="submit" class="submit" />
</form>
I want the submit to act a a straight redirect.. w/ appending the ?username=&password= to the redirect.
If it makes a difference this is an html5 project for android using phonegap.
If I understood correctly, you just want to submit the form and go to another page, while appending the form's fields to the URL as a query string (?foo=bar&foo=bar). For that you have to declare your form's method as GET, like so:
<form method="GET" action="portal.html" class="forms">
EDIT: turns out the desired behavior is exactly the opposite.
To don't append a query string, you could set your form's method to POST
<form method="POST" action="portal.html" class="forms">
I am using Jsoup in my application and I am attempting to parse information from an a few input tags in order to add them to a url and post data automatically.
The portion of HTML I am attempting to parse is as follow:
<div class='theDivClass'>
<form method="post" id="handlePurchase" name="makePurchase" action="/shop.php">
<input type="hidden" name="ProductCode" value="A1223MN" />
<input type="hidden" name="SystemVersion" value="3" >
<input type="hidden" name="ProductClass" value="BOOK" />
</form>
</div>
The desired output would be
x = A1223MN
y = 3
z = BOOK
I am halfway familiar with JSOUP in the sense that I am able to parse out text, images, and urls but for some reason this is not clicking for me.
Any help would be greatly appreciated.
You should be able to use this:
Elements hidden = doc.select("input[type=hidden]");
And then just pull the attr values from each element in hidden. I've just tried it and it seems to work as expected.
For completeness:
Map<String,String> hiddenList = new HashMap<String, String>();
Elements hidden = doc.select("input[type=hidden]");
for (Element el1 : hidden){
hiddenList.put(el1.attr("name"),el1.attr("value");
}
Will give you a Map of all hidden input fields in the document.
Element.select("input[name=productCode]").attr("value");
Element.select("input[name=SystemVersion]").attr("value");
Element.select("input[name=ProductClass]").attr("value");
There's another way I found:
FormElement f = (FormElement) doc.select("form#handlePurchase").first();
System.out.println(f.formData());
Result:
[ProductCode=A1223MN, SystemVersion=3, ProductClass=BOOK]
Closing this question as it appears from all of the research I have done, you cannot pull data from "hidden" input types.