Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to retrieve a value from database on click event and display it in HTML5 using (jqtouch+database+jquery)
    primarykey
    data
    text
    <p>I am trying to make an iPhone application for mobile health using HTML5, JavaScript, jqtouch and phonegap. I am doing this as a school project to learn building an iPhone app using HTML5, jqtouch and phonegap.</p> <p>My Database has a unique id, pName and a record. I am able to retrieve a complete list of pName from database able to populate on HTML5 page as list. I am not able to retrieve the pName and record from the database on click event made on the list of pName. I just need to retrieve the pName and record associated with the pName shown on the list. </p> <p>The refreshEntries() is used to retrieve all the data from the database and to populate the entire pName list on patientList panel. It also takes care of onclick event of the pName list. </p> <p>The detailEntryById(id) pick the data associated with the pName clicked and populate it in the patient panel. </p> <p>index.html looks like this </p> <pre><code> &lt;div id="patientList"&gt; &lt;div class="toolbar"&gt; &lt;h1&gt;patientList&lt;/h1&gt; &lt;a class="button slideup" href="#newEntry"&gt;+&lt;/a&gt; &lt;/div&gt; &lt;ul class="edgetoedge"&gt; &lt;li id="entryTemplate" class="arrow" style="display:none"&gt; &lt;a href="#patient"&gt;&lt;span class="label"&gt;Label&lt;/a&gt;&lt;/span&gt; &lt;/li&gt; &lt;/ul&gt; &lt;/div&gt; &lt;div id="patient"&gt; &lt;div class="toolbar"&gt; &lt;a class="button back" href="#"&gt;Back&lt;/a&gt; &lt;h1 id ="patientHeading" style="display:none"&gt; &lt;span class="label1"&gt;Label&lt;/span&gt; &lt;/h1&gt; &lt;a class="button edit" href="#editPatientRecord"&gt;Edit&lt;/a&gt; &lt;/div&gt; &lt;br/&gt; &lt;form method="post"&gt; &lt;img class="displayed" src="kilo.png" alt="patient photo" width="70" height="70" /&gt; &lt;ul class="rounded"&gt; &lt;li&gt;&lt;input type="text" placeholder="patient record" name="record" id="record" autocapitalize="off" autocorrect="off" autocomplete="off" /&gt;&lt;/li&gt; &lt;/ul&gt; &lt;ul class="rounded"&gt; &lt;li&gt;&lt;input type="submit" class="submit" name="action" value="Save Entry" /&gt;&lt;/li&gt; &lt;/ul&gt; &lt;/form&gt; &lt;/div&gt; </code></pre> <p>iPhone.js code </p> <pre><code> function refreshEntries() { $('#patientList ul li:gt(0)').remove(); db.transaction( function(transaction) { transaction.executeSql( 'SELECT * FROM patientRecord1;',[], function (transaction, result) { for (var i=0; i &lt; result.rows.length; i++) { var row = result.rows.item(i); var newEntryRow = $('#entryTemplate').clone(); newEntryRow.removeAttr('id'); newEntryRow.removeAttr('style'); newEntryRow.data('entryId', row.id); newEntryRow.appendTo('#patientList ul'); newEntryRow.find('.label').text(row.pName); newEntryRow.find('.label').click(function(){ var clickedEntry = $(this).parent(); var clickedEntryId = clickedEntry.data('entryId'); detailEntryById(clickedEntryId); }); // end of click function } // end of for loop }, // end of function (transaction,result) errorHandler ); // end of transaction.executeSql } // end of function transaction ); // end of db.transaction } // end of function refreshEntries function detailEntryById(id) { db.transaction( function(transaction) { transaction.executeSql('SELECT * FROM patientRecord1 WHERE id=?;', [id], function(transaction, result){ for (var i=0; i &lt; result.rows.length; i++){ var row = result.rows.item[i]; var patientClicked = $('#patientHeading').clone(); patientClicked.removeAttr('id'); patientClicked.removeAttr('style'); patientClicked.appendTo('#patient h1'); patientClicked.find('.label1').text(row.pName); } // end of for loop }, // end of function(transaction , result) errorHandler); // end of executeSql } // end of function transaction ); // end of db.transaction } </code></pre> <p>Please tell me where I am doing wrong.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload