Im working on a mobile web app using jQTouch for the theme. Im having an issue trying to pass a hyperlink parameter/value to a javascript function. The link is part of a list that is generated from a websql query:
THIS IS THE LIST - which nicely display with only the ID of a row set to "xres" as an id on a div tag in the main HTML
function dspList() {
db.transaction(function (tx) {
tx.executeSql('SELECT * FROM UBP', [], function (tx, results) {
var len = results.rows.length, i;
for (i = 0; i < len; i++){
xres = "<li class='arrow'><a href='#userdisplay' önclick='dspUser()'>" + results.rows.item(i).uaid + "</a></li>";
document.querySelector('#xres').innerHTML += xres;
}
}, null);
});
}
THIS IS THE HTML TAG THAT DISPLAYS THE LIST:
<div id="myinfo">
<div class="toolbar">
<h1>My Info</h1>
<a class="button back" href="#home" önclick="goRefresh(0)">Back</a>
</div>
<ul class="edgetoedge">
<div id="xres"></div>
</ul>
</div>
When clicking one of the items on the list, ie:
3459
4436
2255
..it runs this javascript function:
function dspUser() {
var xuaid = document.getElementById("xres");
db.transaction(function (tx) {
tx.executeSql('SELECT * FROM UBP WHERE (uaid = ?) ', [xuaid], function (tx, results) {
{
xres1 = results.rows.item(0).uaid + " - " + results.rows.item(0).user;
document.querySelector('#xres1').innerHTML += xres1;
}
}, null);
});
}
..and displays with this HTML:
<div id="userdisplay">
<div class="toolbar">
<h1>User Information</h1>
<a class="button back" href="#myinfo">Back</a>
</div>
<div>
<ul class="plain12">
<span class="fontleft18"><div id="xres1">Results here..</div></span>
</ul>
</div>
</div>
Im very new at javascript, but would really like to learn and build some web apps. Can anyone help me figure out why I cant pass the value of the id=xres to the function dspUser() so that I can query the websql for just that particular id/row? Am I using the correct function with the document.getElementById? Is this even the correct way/process to query the websql from a list display that was also generated by a websql query?
Any help would be greatly appreciated.
Octavious