[Solved] what is the error in javascripts i had already define the function but it could not find the defination

Firstable as I say convWt() is not the same as convWT(). Then, you should never give the same id to each of your input. Try to make this like : var inp = document.getElementById(‘inp’); var convGram = document.getElementById(‘convGram’); var convPound = document.getElementById(‘convPound’); var convMiliGram = document.getElementById(‘convMiliGram’); var convTon = document.getElementById(‘convTon’); var convOunce = document.getElementById(‘convOunce’); function … Read more

[Solved] javascript change div text on ready [closed]

You wrote about IDs, but in your code is class. <div id=div1>YES</div> <div id=div2></div> <script> var div1 = document.getElementById(‘div1’); var div2 = document.getElementById(‘div2’); if (div1.innerHTML == ‘YES’) { div2.innerHTML = ‘You said YES’; } </script> http://jsfiddle.net/7r9cwf3s/ OR generally, if you want to put into the second one div ‘You said ‘ and content of the … Read more

[Solved] How do I add class using jquery/javascript to different elements depending on what day is it?

You don’t need jQuery to check what date it is. You can use plain Javascript for that. var today = new Date(); if(today.getDate() === 17) { $(‘.on-17’).addClass(‘active’); } A more dynamic implementation that always adds class active to the current day’s div: var today = new Date(); var dayOfMonth = today.getDate(); $(‘on-‘ + dayOfMonth).addClass(‘active’); If … Read more

[Solved] What is the most efficient way to convert JSON with multiple objects to array in JavaScript [closed]

Simple solution with two map() operations: const data = [{ “week”: 1, “lost”: 10, “recovery_timespan”: [{ “week”: 2, “count”: 1 }, { “week”: 3, “count”: 0 }] }, { “week”: 2, “lost”: 7, “recovery_timespan”: [{ “week”: 3, “count”: 1 }, { “week”: 4, “count”: 3 }] }, { “week”: 3, “lost”: 8, “recovery_timespan”: [{ “week”: … Read more

[Solved] How do i check if my string contains certain words

It should work like that <button onclick=”myFunction()”>navigate</button> <script> function myFunction() { var url = document.URL; if (window.location.href.indexOf(‘brand’) > -1) { alert(‘yes’); } url = url.replace(‘.html’,’.php’) window.location.href = url; } </script> solved How do i check if my string contains certain words

[Solved] How to multiply each element in an array with a different number (javascript) [closed]

Fixed number for all index var array = [0, 1, 2, 3]; array.map( function(n){ return (n* number to be multiplied); } ); Different number for each index var array = [0, 1, 2, 3], numberToBeMultiplied = [1,3,5,7]; array.map( function(n, i){ return n * numberToBeMultiplied[i]; }); You can also push the returning elements in an array. … Read more

[Solved] If an array has an attribute, find the value of another attribute of the same array? [closed]

I think you need something like bellow. You have a JSON like bellow. var data = {“dTableRowData”: [ { “id”: “1”, “rowData”: [ “tt”, “Sep13, 2010” ], “action”: [ { “hrefvar”: “aaa”, “label”: “fff” }, { “hrefvar”: “bbb”, “label”: “Details” }, { “hrefvar”: “ccc”, “label”: “View” } ] } ]} You want to get an … Read more

[Solved] JavaScript MySQL injection prevention [closed]

For a start, JavaScript is code that a user can actually edit using DOM tools (like inspect element) and should never be used as a mechanism to security with Databases. You should firstly start to research about prepare statements in PDO if you’re using un-trusted user input; the bind paramtter in the PDO interface automatically … Read more

[Solved] When i click on an element add another ID or class

Try .on() As your content is added dynamically so it is not accessible directly ,So you have to use Event delegation. $(“.minwidth_IE”).on(“click”,”#custom_background span”,function () { $(“#account ,.minwidth_IE ,.main .main-head ,#fa_toolbar”).removeClass(“bg1 bg2 bg3 bg4 bg5 bg7 bg8 bg_custom”).addClass(this.id); my_setcookie(“custom_background”, this.id, true) }); 3 solved When i click on an element add another ID or class

[Solved] Reducing object to simple array

Solution 1 var obj= { 0: “United States”, 1: “India”, 2: “Germany”, 3: “Brazil”, 4: “Taiwan”, 5: “Israel”, 6: “United Kingdom” } var result = Object.values(obj) console.log(result); Solution 2 var result = Object.keys(obj).map(function(key) { return obj[key]; }); console.log(result); 1 solved Reducing object to simple array