Reputation: 136
I am using PhoneGap and jQuery Mobile and am having difficulty capturing inputted form data.
I have a simple form text field reading:
<input name="which_entry_final" id="which_entry_final" type="text" value="777">
The form has a button reading:
<button onclick='alert( $('#which_entry_final').val() );'>Save</button>
The alert should display whatever the user typed into the field. However in PhoneGap, it always shows "777" (the default value), no matter what is typed into the field.
This only seems to be an issue in PhoneGap. When I run it on a regular webserver, it works properly. Any advice?
Upvotes: 2
Views: 1093
Reputation: 257
You can just change value="777"; to value=""; or you can use the following code (it's working fine)
<script type="text/javascript">
$(document).ready(function(e) {
$(".btn").click(checkValue);
});
function checkValue() {
var v1=$("#textinput").val();
alert(v1);
}
</script>
and the html code is
<input type="text" name="textinput" id="textinput" value="" />
<a id="b" class="btn" data-role="button">Submit</a>
Upvotes: 1