Fill javascript arrays from html form - javascript

I have a PLSQL form with multiple duplicate elements. example:
row1 - name, number, address
row2 - name, number, address
row3 - name, number, address
Is there a way to collect each row name into a javascript array then each row number into the second array, etc. Then send the values as an array to the PLSQL procedure to process each transaction to the DB.
function(){
var name = [document.getElementById("name").value];
var number = [document.getElementById("number").value];
var address = [document.getElementById("address").value];
window.location.href = https://server/schema.package.procedure?name="+name+"&number="+number+"&address="+address+"";
}

Related

I have to make changes in a logic where it fetches data from MySQL using certain conditions and I'm not sure how to do it?

Okay so first
async getPRMsAvailability() {
var prmsData = await getManager().query(
'SELECT SQL_NO_CACHE prm.id, prm.firstName, prm.lastName, COUNT(student.id) as students FROM prm LEFT JOIN student ON prm.id = student.prm_id group by prm.id order by count(student.id) asc limit 1'
);
return prmsData;
}
This is the code that is already present in my file what this code does is from the prm table it takes id, firstname, lastname and assigns it to the total count of student ids present in student table the only change I want here is that it should also consider the status column from the student table and only consider it for those students whose status(student.status) is active and not all students.

getRange/setValues does not always work

I help maintain a Google spreadsheet where new data is added via a HTML form.
When it comes to add new data the insertion point of the new data depends on one of the form fields (Application Received date).
The script finds where in the sheet the data should be inserted and does 3 things:
Inserts a blank row at the correct location
Copies the row above (so formulas and conditional formatting are copied)
Replaces the data in the cells from the copy with the values entered into the form
The issue is cells A to I are value based (populated from the form) and so are cells M to O, but cells J,K,L are calculations based on some cells in A to I.
This means I have to make 2 calls to getRange/setValues and sometimes the second call (the call to set cells M,N,O does not work. The result is a new row created with the correct data in cells A to I (and thus J,K,L) but cells M,N,O stay as whatever is in those cells in the row above.
Here is the relevant code.
// Assign object data for cells A to I
var newvalues = [
[ username, applyDate, maritalStatus, sponsorApprovalDate, processingOffice, inProcessDate, extraDocsRequestedDate, nonVisaExempt, decisionMadeDate ]
];
// Set cells A to I with data from form
sheet.getRange('A' + startingRowIndex + ':I' + startingRowIndex).setValues(newvalues);
// Now assign object data for cells M to O
newvalues = [
[ coprReceivedDate, location, notes ]
];
// Set cells M to O with data from form
sheet.getRange('M' + startingRowIndex + ':O' + startingRowIndex).setValues(newvalues);
As stated above the second sheet.getRange('...').SetValues() call fails to set the values.
Any ideas?
Instead of completely recalculating the locations of your output ranges, you could get an "anchor" point at the start of the row, then use the Range.offset() method to define additional ranges relative to the anchor.
// Assign object data for cells A to I
var newvalues = [
[ username, applyDate, maritalStatus, sponsorApprovalDate, processingOffice, inProcessDate, extraDocsRequestedDate, nonVisaExempt, decisionMadeDate ]
];
// Get range "anchor" for data from form
var newRow = sheet.getRange('A' + startingRowIndex );
// Set cells A to I with data from form
newRow.offset(0,0,newvalues.length,newvalues[0].length).setValues(newvalues);
// Now assign object data for cells M to O
newvalues = [
[ coprReceivedDate, location, notes ]
];
// Set cells M to O with data from form
newRow.offset(0,13,newvalues.length,newvalues[0].length).setValues(newvalues);

Jquery, getting the column data of selected row using jtable

I have 3 fields in my jtable; Name, Age, Occupation.Lets say I select a specific row, How would i get the specific column data of that row?
Ex:
I select the following row:
Row 2: Joe Brown, 25, Teacher
How would I get the age data (which is 25) of that row ?
Thanks
PS: I intend to delete that row, so I need the name to query the sql database properly (im using jdbc)
$('#yourTable tr').each(function() {
var age = $(this).find("td").eq(1).html();
alert(age);// for testing purpose
});
You will get the value of the second row (the index is zero-based)
var rowIndex = // the zero based index of the selected row
var age = $('.jtable tbody').children(rowIndex).children('td').eq(1).text(); // return the age

Javascript: Searching indexeddb using multiple indexes

I want to change from WebSql to Indexeddb. However, how would one do SQL queries like
SELECT * FROM customers WHERE ssn = '444-44-4444' and emal = 'bill#bill#company.com'
SELECT * FROM customers WHERE ssn = '444-44-4444' and emal = 'bill#bill#company.com' and age = 30
SELECT * FROM customers WHERE ssn = '444-44-4444' and emal = 'bill#bill#company.com' and name = 'Bill'
etc
with IndexedDB ?
For example, I noticed while reading the documentation of indexedDb, that all the examples only query one index at the time. So you can do
var index = objectStore.index("ssn");
index.get("444-44-4444").onsuccess = function(event) {
alert("Name is " + event.target.result.name);
};
But I need to query multiple indexes at the same time!
I also found some interesting posts about compound indexes, but they only work if you query for all the fields in the compound index.
For your example, compound index still work, but requires two compound indexes
objectStore.createIndex('ssn, email, age', ['ssn', 'email', 'age']); // corrected
objectStore.createIndex('ssn, email, name', ['ssn', 'email', 'name'])
And query like this
keyRange = IDBKeyRange.bound(
['444-44-4444', 'bill#bill#company.com'],
['444-44-4444', 'bill#bill#company.com', ''])
objectStore.index('ssn, email, age').get(keyRange)
objectStore.index('ssn, email, age').get(['444-44-4444', 'bill#bill#company.com', 30])
objectStore.index('ssn, email, name').get(['444-44-4444', 'bill#bill#company.com', 'Bill'])
Indexes can be arranged in any order, but it is most efficient if most specific come first.
Alternatively, you can also use key joining. Key joining requires four (single) indexes. Four indexes take less storage space and more general. For example, the following query require another compound index
SELECT * FROM customers WHERE ssn = '444-44-4444' and name = 'Bill' and age = 30
Key joining still work for that query.

How to take data from Ext.Record?

I can take record from store: var record = store.getAt(i);
But if i want to take fileds which have a same name from record i get only first field value. For example if i have XML with:
Code:
<zem>
<parcel>
....
<parcel>
<really>
<price>555.555<price>
</really>
<really>
<price>666.666<price>
</really>
</zem>
And using record.get("price") i can get only 555.555 value.
Its possible to get values of all fields of <really>? Or array of values of all fields with name=<price>?
Take a walk on store:
var res = [];
store.each(function(record) { res.push(record.get('price')); })

Categories