I have a jQuery mobile project which will allow users to enter data in a form which will then (after submit) perform some JavaScript calculations on the client-side and return a useful output.
I can't work out the fundamental process for passing the input data to the output field upon "submit" let alone performing any calculations or manipulations of the data.
In the example below I want the user to enter their name and upon submit a new page loads with the name already filled in. What actually happens is that the form loads nicely, and on submit shows the report page but the name field remains blank
<form action="#report" name="formInput" method="post"data-ajax="false">
<div class="ui-field-contain">
<label for="name-1">Name:</label>
<input name="name-1" id="name-1" value="" minlength="2" type="text" />
</div>
<div class="ui-grid-a">
<div class="ui-block-a"><input type="reset" value="Reset" data-icon="back"data-theme="a"/></div>
<div class="ui-block-b"><button type="submit" name="submit" value="submit"onclick="yourName();" data-theme="a">Submit</button></div>
</div>
</form>
</div>
</div>
<!-- Start of third page -->
<div data-role="page"data-theme="b"data-add-back-btn="true" data-back-btn-text = "Home" id="report">
<div data-role="header">
<a href="#" data-icon="back" data-rel="back" title="Go back">Back</a><h1>This is your name</h1>
</div>
<div data-role="content">
<label for="name-rep">Name:</label>
<input name="name-rep" id="name-rep" value="" minlength="2" type="text" />
</div>
My JavaScript is:
enter code here
$("#formInput").submit(function(e){
var name = $('#name-1').val();
$('#name-rep').val(name);
});
Or maybe
function yourName() {
var name = $('#name-1').val();
$('#name-rep').val(name);
}; `