[Solved] convert arrays to a single array of objects

If they are all in the same order, you can do this: var firstname = [“john”, “peter”, “rick”]; var age = [20, 45, 30]; var country = [“Brazil”, “USA”, “Italy”]; var array = []; for (var i = 0; i < firstname.length; i++) { array.push({firstname: firstname[i], age: age[i], country: country[i]}); } console.log( JSON.stringify(array) ); Note … Read more

[Solved] is there jade plugin that would allow manipulation using jquery styled syntax

This code does more or less what i wanted. And it’s natively supported. It’s called conditional attributes in docs. You can find more information about it in attribute section. Only works with latest version of jade. //- Suppose object passed is this – var selected=’about’; li(class={selected:selected==”home”}) Home li(class={selected:selected==”blog”}) Blog li(class={selected:selected==”about”}) About ..Will result in this: … Read more

[Solved] How to randomly pick a number of combinations from all the combinations efficiently

If you have F unique first names and L unique last names, then overall number of combinations is N = F * L So you can generate needed number of non-repeating random integer values in range 0..N-1 (for example, with Fisher-Yates sampling), sort them, and get corresponding name combinations: for i = 0..M-1 Generate K[i] … Read more

[Solved] send mail form not sending mail

You need some server side code to send the mail. Just having a form doesn’t do anything for you So to send it on that click: $(‘#sendMessage’).click(function(e) { var $form = $(‘#tellafriend_form’); $.post($form.get(0).action, $form.serialize(), function(data){ //something on success }) $(“#tellfriend”).fadeToggle(‘fast’); }); 9 solved send mail form not sending mail

[Solved] How to change CSS property before element is created?

I don’t know if that works in all browsers but you could append a new style-node inside your head section like this: var marginTop = …; var node = document.createElement(“style”); node.setAttribute(“rel”, “stylesheet”); node.innerHTML = “div { margin-top: ” + marginTop + “px; }”; document.head.appendChild(node); Your head element must obviously exist for this to work. I … Read more

[Solved] Javascript and “div” Tags

Looks like you were close you just need to take a little more time checking your formatting… There are a lot of unanswered questions here but this is what you were shooting for, I think. <head> <style type=”text/css”> .ok { background-color:green; } .dead { background-color:red; } </style> <script src=”https://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js”></script> <script type=”text/javascript”> var variable1 = ‘<?php … Read more

[Solved] I have a number and I need to format it to billion or million

The toFixed() method converts a number into a string, keeping a specified number of decimals. Here is the JsFiddle link https://jsfiddle.net/zco2d5x1/ function fnum(x) { if (x < 1000000000) { alert((x / 1000000).toFixed(2) + “M”); } else if (x < 1000000000000) { alert((x / 1000000000).toFixed(2) + “B”); } else alert(“More”); } fnum(136866516683); 0 solved I have … Read more