How to read JSON using javascript?

Uncategorized
Question: I have JSON data like this - { "details": [ { "A": { "Name": "mike", "Age": 22 }, "B": { "Name": "John", "Age": 25 } } ] } I want to read A,B points as an array. Answer: Another way to do it with your json, Object.keys(),since your options are not in array form, can use that to convert to array form. var json = { "details": [ { "A": { "Name": "mike", "Age": 22 }, "B": { "Name": "John", "Age": 25 } } ] } var outputDiv = document.getElementById('output'); var options = Object.keys(json.details[0]).map(function(item){ return ''+ item +'' }) options.unshift(' Please select ') var select = document.getElementById('your_options'); select.innerHTML = options.join() select.onchange = function() { outputDiv.innerHTML = JSON.stringify(json.details[0][this.value]); } You options Read more
Read More

MySQL SQL Syntx Error 1064

Uncategorized
Question: I want to create table like this, CREATE TABLE playerinfo ( uuid varchar(255) NOT NULL PRIMARY KEY, nickname varchar(255) NOT NULL, firstplayed varchar(255) NOT NULL, lastonline varchar(255) NOT NULL, playtime bigint NOT NULL DEFAULT 0, unit int NOT NULL DEFAULT 0, kill int NOT NULL DEFAULT 0, death int NOT NULL DEFAULT 0 ); But I couldn't create table by Syntax Error 1064, in 'kill int NOT NULL DEFAULT 0, death int NOT NULL DEFAULT 0', I can't find error in there. the simillar command 'unit int NOT NULL DEFAULT 0' doesn't cause the error, what should I do? Answer: KILL is a reserved SQL keyword. You'll have to name that column of your table something else. A list of reserved keywords can be found here: https://dev.mysql.com/doc/refman/5.7/en/keywords.html Read more
Read More

array_chunk in email body php

Uncategorized
Question: I have a form where user can click on a button to add as many partecipants as he needs. For every partecipant I have 4 fields. Those fields are automatically added with a script when I click on the button to add partecipants. The fields are created as [data] so I have this in my php file to send the email:if(isset($_REQUEST['data'])){ $postdata = $_REQUEST['data']; } if( isset($postdata) ) { $altri = implode('', array_chunk($postdata, 4, true)); } else { $altri = 'Non sono stati aggiunti altri partecipati a questa richiesta'; } then in my $body I try to print the result as:$body =
Read More

Add mobile frame in wordpress to showcase mobile app live [on hold]

Uncategorized
Question: I wanted to create a mobile app showcase for business. Where I will make them mobile app both for android and ios. To show my customers a live projection/showcase I want to add a mobile frame in my WordPress page where customers will input their business website's link and they will see a live projection of my app for their business websites. Basically, I will use android webview to create that app. Can any one help me with this? Answer: Read more
Read More

React Native Navigation Drawer overlap status bar

Uncategorized
Question: The React Navigation Drawer overlaps with the Android status bar. Is there a way to prevent that? Source here contentOptions: { style: { marginTop: 24, }, }, This only gives margin to the content, not the whole drawer. Answer: Try this hope it was helpful for you 1.Make "Header layout" in which, what you want to like image and text. enter image description here(prepare a custom menu-drawer) Then make another layout for drawer-menu. This is Parent_main Make Class For navigation Adapter public class NavigationDrawerAdapter extends RecyclerView.Adapter { private LayoutInflater inflater; private List focusHeader; private Context context; public static boolean Snackbar snackbar; String[] name={ "About Focus", "FAQ", "Help"}; Integer[] image_ID={ R.drawable.logo, R.drawable.faq, R.drawable.help,}; Intent intent; public NavigationDrawerAdapter(List focusHeader,Context context) { this.focusHeader=focusHeader; this.context = context; inflater = LayoutInflater.from(context);} @Override public MyViewHolder…
Read More

Align Icons at top without offsetting height

css
Question: I am trying to align just the camera icons at the top directly below the it's as easy as title. However when I increase the amount of text below the title it pushes down the other components. Its As Easy As ... //wrapper for all 3 // Icon with title component {title} {desc} ...repeat 2 more for the others I am passing in some text in the desc attribute and when that text is long it pushes the other components down. I tried setting a fixed height but that just increased the overall height of the components. How would I align the icons so that the long text in the desc field does not affect the other components height? Answer: you could try to make your top level div…
Read More

angularjs input file onchange error in jhipster webapp [duplicate]

Uncategorized
Question: This question already has an answer here:ng-model for 10 answers AngularJS v1.5.8 $scope.uploadImage = function(){ alert("change"); } error in console: Uncaught TypeError: Cannot read property 'uploadImage' of undefined at HTMLInputElement.onchange Answer: I think you have setup angular wrong, it should work like this:- var app = angular.module("myApp", []); app.controller("myCtrl", function($scope) { $scope.uploadImage = function() { alert("change"); } }); Read more
Read More

How to import a script into a vue.js component?

Uncategorized
Question: I've purchased a plugin called filePicker that I want to use in one of my vue.js components. The plugin author shows only the usual way to import the js scripts at the end of the element like so: In my component, I did the following: The first import filepicker.js works but with the 2nd (filepicker-drop) I get the following error when I try to compile ERROR Failed to compile with 1 errors This dependency was not found: * fs in ./node_modules/request/lib/har.js To install it, you can run: npm install --save fs Running npm install --save fs doesn't remove the error. The file filepicker-drop.js includes this:(function (global, factory) { typeof exports === 'object' && typeof module !== 'undefined' ? factory(require('jquery'), require('filepicker')) :typeof define === 'function' && define.amd ? define(['jquery', 'filepicker'],…
Read More

Request – Response API for Android Wear 2.0?

Uncategorized
Question: How do I implement a request-response protocol for an Android Wear 2.0 app? Scenario: When I tap on a button on the watch, I want it to fetch some data from the phone and display it on the watch's screen. What I tried: I implemented a working example using the MessageApi, but I don't like it. I send a dummy "request" in one place using one method, I disregard the PendingResult and then hope that eventually I will receive a message that will be a corresponding response. Ideally, what I'd like to have is: byte[] responseBytes = sendRequest(someRequestBytes); Answer: I'm not sure what you have tried. But this code should work to send a byte array. Wearable.MessageApi.sendMessage(googleApiClient, transcriptionNodeId, VOICE_TRANSCRIPTION_MESSAGE_PATH, voiceData).setResultCallback( new ResultCallback() { @Override public void onResult(SendMessageResult sendMessageResult) {…
Read More