i am new to xpages, but i want to try to create a response document for a main document which is the order document. there is a product document which display the view of all product in the database and with a checkbox, both document are on one page. using the below code on the onclick event if the checkbox
var colName = view1Collection.getColumnValue("Name");
var prodNameScope = sessionScope.get("scopeProdName");
var docIdScope = sessionScope.get("scopeDocID");
var selDocID = view1Collection.getUniversalID();
if(docIdScope .contains(selDocID )) {
prodNameScope .remove(colName );
docIdScope .remove(selDocID );
} else {
prodNameScope .add(colName );
docIdScope .add(selDocID );
}
Postopen event:
var nameList = new java.util.ArrayList();
sessionScope.put('scopeProdName', nameList );
var idList = new java.util.ArrayList();
sessionScope.put('scopeDocID', idList );
On the next pages the item displayed well, but i want the selected item to be copied and save as a response document to the main document.
i have tried the below script but did not work:
var PN = sessionScope.get("scopeProdName[indexRowdata]");
document1.replaceItemValue("_Title", PN);
anyone have idea how i could go about this.
thanks in advance.
if you display the articles in a view control you can get the id:s of then using
var myArray = sessionScope.get("projectName");
var PNu = sessionScope.get("projectNumber");
document1.replaceItemValue("ProjectName", myArray);
document1.replaceItemValue("ProjectNumber", PNu);
var PN:java.util.ArrayList = sessionScope.get("scopeProdName");
document1.save()
var Id:java.util.ArrayList=sessionScope.get("scopeDocID");
for(var x=0;x<Id.size();x++){
var doc=database.getDocumentByUNID(Id.get(x));
var newdoc:NotesDocument=doc.copyToDatabase(database);
newdoc.makeResponse(document1.getDocument());
newdoc.save();
}
Related
I currently quiet new in DataTable jquery .So I faced a big issue right now .I have a table that using a DataTable jquery to create a child rows.That data are get from database.
Every rows in table have a checkbox and will be submit all the selected child rows. My problem is when I want to submit the data ,it seems my code not working as I want if I changing the paginator.Thats meant ,when I select all rows in page 1 and page 2 ,there are only rows in page 2 are submitted .Please anybody help me .Below is my code for your reference. Any help will be appreciate.
All rows that are checked will be submited by click on button
$('#OthersSubmit2').on('click', function(e){
var type_of_invoice = $('#TypeInvoiceId2').val();
var program_id = $('#ProgramId2').val();
var sponsorship_id = $('#SponsorshipId2').val();
var result = [];
var data_filter = [];
data_filter = {'type_of_invoice': type_of_invoice,
'program_id':program_id,
'sponsorship_id':sponsorship_id};
var rowcollection = table.$("input:checked", {"page": "all"});
$.each($(rowcollection), function(index,rows) {
var data = $(this).parents('tr:eq(0)');
var transaction = [];
var data2 = [];
var stu_master_id = $(data).find('td:eq(0)').attr('id');
var a = $(data).parent().find('table[id='+stu_master_id+']');
console.log(a);
var sub_tbl = $(a).DataTable().$("input:checked", {"page": "all"});
$.each($(sub_tbl), function(index2,rows2) {
data2 = $(this).parents('tr:eq(0)');
var d = $(data2).find('td:eq(0)').attr('id');
transaction.push(d);
});
result.push({'stu_master_id':stu_master_id,
'transaction_id':transaction});
});
data_filter['data'] = result;
});
I have One simple registration Form which is developed in C#.Net. This form also contain one Grid view which display data from database.In this,I want to disable Insert button when i select particular raw data. and i had develop this code in jquery. I used below code.
function DoStuff(lnk) {
debugger;
var grid = document.getElementById('GridView1');
var cell, row, rowIndex, cellIndex;
cell = lnk.parentNode;
row = cell.parentNode;
rowIndex = row.rowIndex;
cellIndex = cell.cellIndex;
var rowId = grid.rows[rowIndex].cells[0].textContent;
var rowname = grid.rows[rowIndex].cells[1].textContent;
var rowcontact = grid.rows[rowIndex].cells[2].innerHTML;
var rowaddress = grid.rows[rowIndex].cells[3].innerHTML;
var rowemail = grid.rows[rowIndex].cells[4].innerHTML;
var Id = document.getElementById('txt_Id');
var name = document.getElementById('txt_Name');
var contact = document.getElementById('txt_PhoneNumber');
var address = document.getElementById('txt_Address');
var email = document.getElementById('txt_EmailId');
Id.value = rowId;
name.value = rowname;
contact.value = rowcontact;
address.value = rowaddress;
email.value = rowemail;
document.getElementById('Button1').disabled = true;
};
But when i run that page it becomes disable and immediately enable automatically.....:(
Can anyone give me solution ???
You have to call this function after form is completely loaded.
Use below code to make it that happen if you are using jQuery.
$( document ).ready(function() {
DoStuff(lnk);
});
I am creating an app in which I have used jQuery mobile autocomplete the listview data is created dynamically from the database the autocomplete listview code is return in the js file. I am able to select the data from the listview and show it in the input field of the autocomplete and then disable the search list.
Know what I want is seens I am get the data from the data base when user select the list data it will display the name but when it click on the save button it should save the id of that name instead of the name in jQuery ui autocomplete its easy because there we can use array with label and value.
But I don't know how to do it in jQuery mobile.
The code for creating the autocomplete in here:
var db = window.openDatabase("Database", "1.0","BPS CRM", 200000);
$( document ).on( "pageinit", "#myPage", function() {
var usrname = new Array();
$( "#autocomplete" ).on( "listviewbeforefilter", function ( e, data ) {
var $ul = $( this ),
$input = $( data.input ),
value = $input.val(),
html = "";
$ul.html( "" );
db.transaction(function(tx){
tx.executeSql('select * from users',[],function(tx,results){
var dataset = results.rows;
if(dataset.length > 0){
for(var i = 0; i < dataset.length; i++){
usrname[i] = dataset.item(i).user_name;
}
}
});
});
if ( value && value.length > 1 ) {
for(var j = 0; j < usrname.length; j++){
html += "<li>"+usrname[j]+"</li>";
}
$ul.html( html );
$ul.listview( "refresh" );
$ul.trigger( "updatelayout");
$.mobile.activePage.find('input[placeholder="Find a city..."]').attr('id','namesearch');
}
$("ul > li").click(function(){
var textval = $(this).text();
$('#namesearch').val(textval);
$.mobile.activePage.find("[data-role=listview]").children().addClass('ui-screen-hidden');
});
}); });
It will great if small example is given for the same.
Any suggestion is appreciated. Thanks in advance.
I am not exactly sure I understood the question, but I think what your are looking for is to store the user ID in the <li> elements, in addition to having the username as the displayed text.
Something like this might do the job for you:
// declare a collection of Ids where you declare usrname
var usrids = new Array();
// in your execute sql callback, add this line:
usrids.push(dataset.item(i).user_id); // see note below
// in your for loop where you insert li's, modify the line like this :
html +="<li data-userid='" + usrids[j] + "'>"+usrname[j]+"</li>";
// then in your ul>li click event, you can reference your ids like this :
var userId = $(this).data('userid');
Also, as a general note, I think it's better to use usrids.push(...) and usrname.push(...) instead of using usrids[i] = ...; when the element i does not already exist in the given array.
I made the following code to replace form fields in a page that I can't edit but only manipulate. However, the code does nothing. In chrome console when I print a variable it works fine. The code is below:
//GET val from drop DROP DOWN
var office_id = FieldIDs["OfficeName"];//Gets the input id
var offices;//gets the value from the drop down
$("#FIELD_"+office_id).change(function(){
offices = $(this).val();
}).change();
//The below gets the id's of all the input fields
var address_id = FieldIDs["Address"];
var address2_id = FieldIDs["Address2"];
var city_id = FieldIDs["City"];
var state_id = FieldIDs["State"];
var zip_id = FieldIDs["Zip"];
var phone_4id = FieldIDs["Number4"];//phone
var phone_id = FieldIDs["Number1"];//fax
var pdfm4 = FieldIDs["pdfm4"];
var pdfm = FieldIDs["pdfm"];
if(offices == "SoCal Accounting"){
$('#FIELD_'+address_id).val("7421 Orangewood Avenue");
$('#FIELD_'+address2_id).val("");
$('#FIELD_'+city_id).val("Garden Grove");
$('#FIELD_'+state_id).val("CA");
$('#FIELD_'+zip_id).val("92841");
$('#FIELD_'+phone_4id).val("+1 714.901.5800");//phone
$('#FIELD_'+phone_id).val("+1 714.901.5811");//fax
}
I have a javascript code that displays data in a table format and when hovered over the first column it displays additional details. The hover over code is using jquery tooltip and the title attribute of html. The code works fine in most cases but if one of the fields I am displaying in the hover has " symbol it screws up everything that record onwards and the hover and main data display together and the hover doesnt work on those rows.
below is a snapshot of my code
var medicationName = medJSON.MED_DETAILS[medIdx1].ORDER_NAME;
var orderdetails = medJSON.MED_DETAILS[medIdx1].ORD_DETAILS;
var comments = medJSON.MED_DETAILS[medIdx1].ORD_COMMENTS;
var reqStart = medJSON.MED_DETAILS[medIdx1].REQ_ST_DT;
var originalStart = medJSON.MED_DETAILS[medIdx1].ORIG_ORD_DT;
var lastDose = medJSON.MED_DETAILS[medIdx1].LAST_DOSE;
var nextDose = medJSON.MED_DETAILS[medIdx1].NEXT_DOSE;
var stopDt = medJSON.MED_DETAILS[medIdx1].STOP_DT_TM;
var stopReason = medJSON.MED_DETAILS[medIdx1].STOP_REASON;
var enteredBy = medJSON.MED_DETAILS[medIdx1].ORDER_ENTERED_BY;
var status = medJSON.MED_DETAILS[medIdx1].ORD_STATUS;
var simpleDetails = medJSON.MED_DETAILS[medIdx1].CLIN_DISP_LN;
if(nextDose.length == 0)
{
nextDose = "Not Defined";
}
var medHover = ["<table><tr><td><b>Medication:</b></td><td>",medicationName,"</td></tr>"
,"<tr><td><b>Details:</b></td><td>",simpleDetails,"</td></tr>"
//,"<tr><td><b>Order Comments:</b></td><td>",comments,"</td></tr>"
,"<tr><td><b>Request Start:</b></td><td>",reqStart,"</td></tr>"
,"<tr><td width = 200px><b>Original Order Date/Time:</b></td><td>",originalStart,"</td></tr>"
,"<tr><td><b>Last Documented Dose:</b></td><td>",lastDose,"</td></tr>"
,"<tr><td><b>Next Scheduled Dose:</b></td><td>",nextDose,"</td></tr>"
,"<tr><td><b>Stop Date/Time:</b></td><td>",stopDt,"</td></tr>"
,"<tr><td><b>Stop Reason:</b></td><td>",stopReason,"</td></tr>"
,"<tr><td><b>Order Entered By:</b></td><td>",enteredBy,"</td></tr>"
,"<tr><td><b>Status:</b></td><td>",status,"</td></tr>"
,"</table>"]
tempStr1.push("<tr class = 'evenrow' ><td class = 'cmedname custhvr' title=\"",medHover.join(""),"\">",medicationName,"</td><td> ",simpleDetails,"</td></tr>")
thanks,
Sid
Process medHover with:
medHover.join("").replace('\"', '"');
This replaces the quote character with a value usable with HTML.