Unk
unread,May 23, 2012, 4:06:53 PM5/23/12Sign in to reply to author
Sign in to forward
You do not have permission to delete messages in this group
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to phonegap
Hello!
I'm trying to develop a BMI calculator, a sample app!
but when I use a form with the GET method and submit, I got a
AjaxError... look my code:
<html>
<head>
<title>BMI - Body Mass Index App</title>
<meta name="viewport" content="width=device-width, initial-scale=1">
<script src="cordova-1.7.0.js"></script>
<link rel="stylesheet" href="css/themes/default/
jquery.mobile-1.1.0.css" />
<link rel="stylesheet" href="docs/_assets/css/jqm-docs.css" />
<script src="js/jquery.js"></script>
<script src="docs/_assets/js/jqm-docs.js"></script>
<script src="js/jquery.mobile-1.1.0.js"></script>
<SCRIPT>
function getUrlVars()
{
var vars = [], hash;
var hashes =
window.location.href.slice(window.location.href.indexOf('?') +
1).split('&');
for(var i = 0; i < hashes.length; i++)
{
hash = hashes[i].split('=');
vars.push(hash[0]);
vars[hash[0]] = hash[1];
}
return vars;
}</SCRIPT>
</head>
<div id="main" data-role="page" action="#calculate">
<div data-role="content">
<div data-role="header">
<h4>Body Mass Index</h4>
</div>
<B><center>Find your Body Mass Index!</center></b><br>
<form method="get">
<label for="txtNome">Insert your name:</label>
<input id="txtNome" name="txtNome" type="text" height="200px"/><br>
<label for="txtPeso">Select your weight:</label>
<input type="range" name="txtPeso" id="txtPeso" value="0" min="0"
max="200" />
<label for="txtAltura">Select your height (in cm):</label>
<input type="range" name="txtAltura" id="txtAltura" value="120"
min="120" max="230" /><br>
<center><input name="btnTest" type="submit" data-inline="true" data-
theme="a" value="Salvar Dados"><br><br>
<br><a href="#calculate"><input name="btnIr" type="button" data-
inline="true" data-theme="a" value="Calcular"></a></center>
</form>
<div data-role="footer"><center><h5>Footer</h5></center></div>
</div>
</div>
<div id="calculate" data-role="page">
<div data-role="content">
<div data-role="header">
<h1>Body Mass Index</h1>
</div>
<br>
<center><B>Hello,</b> <script>window.document.write(getUrlVars()
["txtNome"]);</script> !</center>
<BR>
<center><b>Your body mass index is:</
b><script>window.document.write(parseFloat(getUrlVars()["txtPeso"]) +
2);</script></center><br> // just testing var convertion...
<a href="#main"><input type="button" value="Go back"></a>
</div>
</div>
</body>
</html>