Skip to main content

Posts

Showing posts from June, 2021

Write a JavaScript Program to print given number of radio buttons

  JavaScript program to print given number of radio buttons: <html lang="en"> <head>     <meta charset="UTF-8">     <meta name="viewport" content="width=device-width, initial-scale=1.0">     <title>Write a code to print numbers of radio buttons in JavaScript</title> </head> <body>     <span id="output"></span> <br><br>     <label for="num1"><input type="radio" name="numbers" onclick="radioBtnClick(this)" id="num1" value="5">5</label>     <label for="num2"><input type="radio" name="numbers" onclick="radioBtnClick(this)" id="num2" value="10">10</label>     <label for="num3"><input type="radio" name="numbers" onclick="radioBtnClick(this)" id="num3" value=...

How create and object and add five key values pair to it in JavaScript?

 Create and object and add five key values pair to it in JavaScript: Developer can use below snippet create and add 5 key-value pairs in it. var obj = {};// an empty object has created for(var i = 1; i<=5; i++){ // A loop has added to add key- values in above object     obj['number'+i] = i; //here we are using Squire brackets [] to add keys & after assignment symbol values. here values are numbers } console.log(obj); Output :

How to remove the duplicate values from two arrays using JavaScript?

 Remove the duplicate values from two arrays using JavaScript: var array1 = [{id:1,name:'Raju',status:'0.Initial'},{id:2,name:'Santosh',status:'1.Capital'}] var idsToRemove = []; array1.forEach(function(dt){     idsToRemove.push(dt.id) }); var array2 =  [{id:1,name:'Raju',status:'0.Initial'},{id:2,name:'Santosh',status:'1.Capital'},{id:3,name:'Jhon',status:'2.Foundation'}] var leftData = []; array2.forEach(function(dt){     if(idsToRemove.indexOf(dt.id) == -1){         leftData.push(dt);     } });  console.log(leftData); Output : Hey user, Thank you for studying the blog Please  comment  if any error/ suggestions found for above data.

How to get next value from map based on dynamic key value in JavaScript?

 Get next value from map based on dynamic key value in JavaScript: The below mapData is a map/object contains place as key and an object (longitude & latitude) as value. We need to get the value, object of the map. The below snippet we can use to get the solutions for it. var mapData = {                  "Brandenburg Gate, Berlin": {latitude: 52.516272, longitude: 13.377722},                  "Dortmund U-Tower": {latitude: 51.515, longitude: 7.453619},                  "London Eye": {latitude: 51.503333, longitude: -0.119722},                  "Kremlin, Moscow": {latitude: 55.751667, longitude: 37.617778},                  "Eiffel Tower, Paris": {latitude: 48.8583, longitude: 2.2945},                  "Riksdag bu...

How to update values in a custom multi lookup field Field (table) of MS Project using JavaScript/jQuery?

  Updating values in the custom multi lookup field Field of MS Project using JavaScript/jQuery: First of all we need to know the steps to update/add details in a Project of Project Server  Step 1: CheckOut a Project Step 2: Update detals in same as in Step 1 Project Step 3: Publish a Project Step 4: CheckIn a Project We always in need to follow the above steps to update any Project to MS Project/Project Server. Same we need to follow in code too.    //Step 1: First, we need to define all the required functions, the below Functions are callback functions             window.checkOutPWAProject = function (projectId, callBack) {                 var checkOutURL = _spPageContextInfo.webAbsoluteUrl + "/_api/ProjectServer/Projects('" + projectId + "')/checkOut()";                 $.ajax({                     url: chec...

"The property '[object Object]' does not exist on type 'SP.Data.StudentsListItem'. Make sure to only use property names that are defined by the type."

  Error: "The property '[object Object]' does not exist on type 'SP.Data.StudentsListItem'. Make sure to only use property names that are defined by the type." Cause : The above issue may come if we are trying to add/update the field name (like 'Student_x0020_Roll') but that field is not available in the Students SharePoint list. OR the field ('Student_x0020_Roll') is look up from some other list but we are trying to updated as text field. ex. var data= { __metadata:{ type:'SP.Data.StudentsListItem' //ListItemEntityTypeFullName for list Student } 'Title':'Ramesh', 'Student_x0020_Roll':'102510', }; Solution: If required Field (like 'Student_x0020_Roll') is not available and required then we need to create it or if not required then we can removed  from saving (from data object). If the required Field (like 'Student_x0020_Roll') is lookup then we need to update it as we are updating for look...

How to values or get entries of a multi select lookup field of a MS Project from Project Server using JavaScript/jQuery Code?

  To get entries or values of a multi select lookup field of a MS Project from Project Server using code:     //First we need Id of custom multi value lookup field             var customFieldId = "d10e13f5-01c2-eb11-bb97-00155dac5921"; //Custom Field ID             function getLookupdata(lookupFieldID) {                 $.ajax({                     url: _spPageContextInfo.webAbsoluteUrl + "/_api/ProjectServer/CustomFields('" + lookupFieldID + "')/LookupEntries",                     method: "GET",                     async: false,                     headers: {                         "accept": "application/json;od...