[Solved] How to generate the combinations of the following in js

okay so after spending sometime i figured it out options = [‘color’, ‘size’]; optionsValues= [[‘Red’,’Blue’], [‘L’, ‘XS’]]; function combination() { var r = [], arg = arguments[0], max = arg.length-1; function helper(arr, i) { for (var j=0, l=arg[i].length; j<l; j++) { var a = arr.slice(0); // clone arr var obj = {}; obj[options[i]] = arg[i][j]; … Read more

[Solved] Can someone tell me what wrong with my code? [closed]

JavaScript 101, check your console for errors, there are a few: extra ; inside json undefined _pcost which should be _cost unfinished/incorrect for loop: ; instead of , inside for loops in JavaScript, + the iteration counter missing var data = { “products”: [{ “p_id”: 111, “p_name”: “p_one”, “p_cost”: 100 }] }; var results = … Read more

[Solved] Iterate over JS [closed]

You where comparing the wrong array in your code, you can fix it like following: for (var currentPokemon in FullGame.pokemon) { // HERE added .pokemon at the end if (FullGame.pokemon[currentPokemon].name == name) { var Detail = FullGame.pokemon[currentPokemon]; alert(Detail); } else { alert(“Type Again”); } } 3 solved Iterate over JS [closed]

[Solved] display calendar (date picker) in html page

As mentioned in the comments, you haven’t included jQuery or jQuery UI, and your HTML closing tags are incorrect. If you view the source of the demo on the jqueryui site, you will find the code is a little different you yours. <!DOCTYPE html> <html> <head> <link rel=”stylesheet” href=”https://code.jquery.com/ui/1.12.1/themes/base/jquery-ui.css”> <script src=”https://code.jquery.com/jquery-1.12.4.js”></script> <script src=”https://code.jquery.com/ui/1.12.1/jquery-ui.js”></script> <script> $(function() … Read more

[Solved] Why javascript code is not working on Microsoft Edge, IE, UC(on mobile), Opera MIni(on mobile), working in Chrome, Firefox [closed]

Without your code we will not be able to identify your problem. But Different browsers render and act differently in some situation. if you use jQuery like library it will be easy to get done what you want. $(document).ready(function() { $(‘input[type=radio][name=type1]’).change(function() { if (this.value == ‘Response’) {//if the value of radio button is male //your … Read more

[Solved] Extract data from nested JSON Node JS

assuming that your JSON is object named data var data = { “destination_addresses” : [ “Chennai, Tamil Nadu, India” ], “origin_addresses” : [ “Kolkata, West Bengal, India” ], “rows” : [ { “elements” : [ { “distance” : { “text” : “1,671 km”, “value” : 1671269 }, “duration” : { “text” : “1 day 5 … Read more

[Solved] Grouping JavaScript array with sum

Do it like this: var array = [{t_id:”1″,val1:”1″,title:”cash to purchase”,unit:”bag”},{t_id:”1″,val1:”1″,title:”cash to purchase”,unit:”bag”},{t_id:”1″,val1:”1″,title:”cash to purchase”,unit:”bag”},{t_id:”2″,val1:”4″,title:”offload”,unit:”bag”},{t_id:”2″,val1:”5″,title:”onroad”,unit:”bag”},{t_id:”3″,val1:”5″,title:”Onroad”,unit:”bag”},{t_id:”3″,val1:”6″,title:”Onroad”,unit:”bag”}]; var grouped = []; array.forEach(function(o) { var count = 0; if (!this[o.t_id]) { this[o.t_id] = { t_id: o.t_id, val1: 0, title: o.title, counter: count }; grouped.push(this[o.t_id]); } this[o.t_id].val1 += Number(o.val1); this[o.t_id].counter += Number(++count); }, Object.create(null)); console.log(grouped); Now in HTML show like … Read more

[Solved] How to use a variable inside a string

Use this code document.getElementById(“aaa:j_idt89:”+ i +”:asd”).innerHTML Note the change I made inside. “+ i +” . You actually needed a String Concatenation. So explaining the code. when i = 1 “aaa:j_idt89:”+ i +”:asd” = “aaa:j_idt89:”+ 1 +”:asd” = “aaa:j_idt89:1:asd” = thats what you need 0 solved How to use a variable inside a string

[Solved] How to get a div of such form that works in all browsers (IE10+)?

In order to ensure both browser compatibility AND a gradient/image background, you may find you will have to use multiple elements, as well as a pseudo element on each of the nested divs. A quick mock up can be seen below. html { background: radial-gradient(red, black); } div.wrap { height: 300px; width: 300px; position: relative; … Read more

[Solved] How to modify an array of objects containing values of the same name?

Something like this might work for you: var i; var k; for(i = 0; i < existingArray.length; i++){ var count = 2; for(k = 0; k < existingArray.length; k ++){ if(i != k && existingArray[i].content.host.name === existingArray[k].content.host.name){ existingArray[k].content.host.name += ‘_’ + count; count++; } } } 3 solved How to modify an array of objects … Read more