Posts

Showing posts from May, 2015

C# How do I get out of this loop? -

how out of loop? i wrote program checks see if corresponding places in numbers same total. console output should true or false. wrote that, , added top part interacts user, , stuck in loop. how out of it? using system; namespace deliverablepart1 { class deliverablepart1 { static void main(string[] args) { string gameanswer; bool repeat1 = true, repeat2 = true; while (repeat1 == true) { repeat2 = true; console.writeline("would compare 2 numbers see if corresponding place same total?"); gameanswer = console.readline(); while (repeat2 == true) { if (gameanswer == "yes" || gameanswer == "yes" || gameanswer == "yes") { console.writeline("please enter 3 digit whole number"); string firstvalue = ...

sql - Increase MySql EAV query performance -

Image
when run query, took average of 1.2421 seconds, think slow, have added indexing every single possible column in clause. anymore improvement can speed query? table contains data eav have around 111276 rows/records select sql_calc_found_rows eav.entid, ent.entname eav, ent, catatt ca eav.entid = ent.entid , ent.status = 'active' , eav.status = 'active' , eav.attid = ca.attid , ca.catid = 1 , eav.catid = 1 , ( ca.canviewby <= 6 || ( ent.addedby = 87 , canviewby <= 6 ) ) , ( ( eav.attid = 13 , ( `char` = '693fafba093bfa35118995860e340dce' ) ) or ( eav.attid = 3 , `double` = 6 ) or ( eav.attid = 45 , ( `int` = 191 ) ) ) group eav.entid having count(*) >= 3 explain output catatt table index eav table index ent table index i have sim...

heroku rails app crashing on mobile devices -

i have rails app on heroku, working quite on system crashes on mobile devices android based phone. i have checked app , looks fine out there here heroku log: 2017-08-20t01:48:46.253573+00:00 app[web.1]: started "/api/notifications.json" 64.233.173.159 @ 2017-08-20 01:48:46 +0000 2017-08-20t01:48:46.258740+00:00 app[web.1]: processing api::notificationscontroller#index json 2017-08-20t01:48:46.261854+00:00 app[web.1]: user load (1.7ms) select "users".* "users" "users"."id" = $1 order "users"."id" asc limit 1 [["id", 3]] 2017-08-20t01:48:46.270078+00:00 app[web.1]: (1.7ms) select count(*) "notifications" "notifications"."is_new" = $1 , "notifications"."recipient_id" = 3 [["is_new", "t"]] 2017-08-20t01:48:46.277519+00:00 app[web.1]: (1.6ms) select count(*) "notifications" "notifications"."rec...

reactjs - What does the at symbol (@) do in ES6 javascript? (ECMAScript 2015) -

i'm looking @ es6 code , don't understand @ symbol when placed in front of variable. closest thing find has private fields? code looking @ redux library : import react, { component } 'react'; import { bindactioncreators } 'redux'; import { connect } 'redux/react'; import counter '../components/counter'; import * counteractions '../actions/counteractions'; @connect(state => ({ counter: state.counter })) export default class counterapp extends component { render() { const { counter, dispatch } = this.props; return ( <counter counter={counter} {...bindactioncreators(counteractions, dispatch)} /> ); } } here blog post found on topic: https://github.com/zenparsing/es-private-fields in blog post examples in context of class - mean when symbol used within module? it's decorator . it's proposal added ecmascript. there multiple es6 , es5 equivalent examples on: https://g...

scapy - How can I get IP of a specific hop for traceroute in python -

addr = socket.gethostbyname('dalitstan.org') target = [addr] result, unans = traceroute(target,maxttl=32) i doing , getting below output. there way here ip of specific hop in variable. , why hop number missing in traceroute result? begin emission: finished send 32 packets. ************************* received 25 packets, got 25 answers, remaining 7 packets 185.53.178.6:tcp80 1 192.168.43.1 11 3 10.71.83.18 11 4 172.16.26.245 11 5 172.26.31.242 11 11 49.44.18.38 11 13 103.198.140.164 11 14 103.198.140.27 11 15 80.81.194.27 11 16 217.64.161.25 11 17 217.64.170.214 11 18 185.53.178.6 sa 19 185.53.178.6 sa 20 185.53.178.6 sa 21 185.53.178.6 sa 22 185.53.178.6 sa 23 185.53.178.6 sa 24 185.53.178.6 sa 25 185.53.178.6 sa 26 185.53.178.6 sa 27 185.53.178.6 sa 28 185.53.178.6 sa 29 185.53.178.6 sa 30 185.53.178.6 sa 31 185.53.178.6 sa 32 185.53.178.6 sa on trying result.get_trace(...

pandas - Column order after multi-index unstack -

output after unstacking data. unstacked using multi-columns unstack(['marketdate','class']) marketdate 2017/08/19 2017/08/18 2017/08/19 class onpeak onpeak offpeak offpeak constraint_id 634 -221.65 -165.28 -116.55 -237.97 644 0.00 2.22 0.00 0.00 1049 -702.05 -936.26 -317.45 -181.72 1281 0.00 -4.68 0.00 0.00 1607 -136.12 -84.74 -31.44 -65.91 what need see in output marketdate , below onpeak , offpeak, not marketdate onpeaks first , offpeaks later. this important further processing. any appreciated. iiuc, need sort_index axis=1 . df.sort_index(axis=1)

shell - How to remove quotes around each element in bash array created from grep capture -

in bash function, using grep capture matching pattern string (selecting files created), , storing captured in array. string assigned variable called output installing route create app/routes/foo.js create app/templates/foo.hbs updating router add route foo installing route-test create tests/unit/routes/foo-test.js after running files=($(echo "$output" | ggrep -op 'create\s\k(.+)')) i confirm capturing intend running echo ${files[*]} . output in terminal looks so app/routes/foo.js app/templates/foo.hbs tests/unit/routes/foo-test.js my goal pass these files arguments npm script ( npm run lint <list of files> ). however, when try plug in variable npm script execution, file names either print out like "app/routes/foo.js" "app/templates/foo.hbs" "tests/unit/routes/foo-test.js" or "app/routes/foo.js app/templates/foo.hbs tests/unit/routes/foo-test.js" the ultimate goal here able run npm run li...

modalpopupextender - two modal popup not working together asp.net -

i have 2 modal popup in page. first popup working expected. add second popup , working first popup stop responding code behind mp3.show(). both popups independent , second inside datalist. if remove second first work expected. below code. <%@ page language="c#" autoeventwireup="true" codefile="test.aspx.cs" inherits="test" %> <%@ register assembly="ajaxcontroltoolkit" namespace="ajaxcontroltoolkit" tagprefix="cc1" %> <!doctype html public "-//w3c//dtd xhtml 1.0 transitional//en" "http://www.w3.org/tr/xhtml1/dtd/xhtml1-transitional.dtd"> <%@ register tagprefix="cp" tagname="titlebar" src="ucheaderjobseeker.ascx" %> <html xmlns="http://www.w3.org/1999/xhtml"> <head runat="server"> <title>jquery ui autocomplete - multiple values</title> <link href="~/styles/stylesheet.c...

materialize - Modal bottom sheets is covered by its overlay -

for details, please take on https://codepen.io/apple0408/pen/zjxgvb 1) overlay covers bottom sheet, , want overlay covers each section separately. after struggling week, find overlay code dropping between , overlay cover things including modal bottom sheet. if want generated in below, should now? hint me? ... <section> <div class="fp-tablecell" style="height:885px;">...</div> <div class="modal-overlay" style="z-index: 10; display: block; opacity: 0.5;"></div> </div></section> i using fullpage.js , materialize modal bottom-sheet overlay. hope questions clear enough , there , teach. much~

javascript - Importing RxJS through System.js in typescript -

i'm trying import rxjs 5 typescript app using system.js module type. it's there, when import * rx "path/to/rxjs/rx"; the rx object doesn't contain module contents of rx directly, has property named 'default' contain module contents: rx.observable.of(1,2,3) ... //does not work, rx.observable undefined rx.default.observable.of(1,2,3) ... //does work, , contains module contents expected my tsconfig looks this: { "compileroptions": { "module": "system", "allowsyntheticdefaultimports" : true, "allowjs" : true, "noimplicitany": true, "removecomments": false, "preserveconstenums": true, "baseurl" : "./", "sourcemap": true, "target": "es6", "lib" : ["dom","es6","dom.iterable","scripthost",...

javascript - WooCommerce Populate Cart Through 3rd Party App -

i'm new woocommerce work javascript/react. trying use them end , create own front end store front. pull of data wc display on store front. once user adds items cart on store front, want them able checkout via wc don't have handle payment. there way populate cart / checkout query string?

java - In JavaFx, how to remove a specific node from a gridpane with the coordinate of it? -

if know specific coordinate of node trying remove, let's "col:3, row: 4", how can remove node in column 3 , row 4? there built-in method can use in java? you need remove node (child) layout (gridpane) public node removenodebyrowcolumnindex(final int row,final int column,gridpane gridpane) { observablelist<node> childrens = gridpane.getchildren(); for(node node : childrens) { if(node instanceof imageview && gridpane.getrowindex(node) == row && gridpane.getcolumnindex(node) == column) { imageview imageview=imageview(node); // use want remove gridpane.getchildren().remove(imageview); break; } } }

binding - Update autoComplete JavaFx? -

Image
i working on javafx project. when add new elements in table of database should update autocomplete ,i did problem showing double context-menu ,we can double autocompletes because call method create autocomplete each adding of new elements. i call method each adding: public void pushbills() { arraylist list = new arraylist<>(); bills = new billheaderdao().findall(); (int = 0; < bills.size(); i++) { list.add(bills.get(i).getidclient()); } autocompletionbinding = textfields.bindautocompletion(searchbill, suggestionprovider.create(list)); } how can resolve problem ? this trick: instead of: textfields.bindautocompletion(textfield, list); , try this: list<string> strings = new arraylist<>(); then create binding between textfield list through: new autocompletiontextfieldbinding<>(textfield, suggestionprovider.create(strings)); so changes, including removing, list, reflected in autocompletion of textf...

Android / iOS App - Device Token Storage System with Custom Server -

so have need limit number of devices can access piece of server software wrote. my question is, since know there's p12 file on ios nothing seemingly similar on android platforms, kind of leaning towards making token server side , storing on device. i thinking pretty simple, user sets server key, , when user authorizes in app validates key (while sending unique id device), , server generate token send client further communications. it's pretty google's auth protocols, in fact might see if can incorporate server perhaps... anyway, main question have is, if client limitations on server side, there way can store token on app securely other encrypting way , saving file on internal/external storage. don't want people able manually enter token somewhere , bypass system. or maybe there's way go it. have dependency service local storage on devices, it's matter of implementation @ point , way go.

mvc5 - Server Error in '/' Application. Could not load file or assembly 'System.Web.WebPages.Deployment, Version=3.0.0.0, -

server error in '/' application. could not load file or assembly 'system.web.webpages.deployment, version=3.0.0.0, culture=neutral, publickeytoken=31bf3856ad364e35' or 1 of dependencies. system cannot find file specified. description: unhandled exception occurred during execution of current web request. please review stack trace more information error , originated in code. exception details: system.io.filenotfoundexception: not load file or assembly 'system.web.webpages.deployment, version=3.0.0.0, culture=neutral, publickeytoken=31bf3856ad364e35' or 1 of dependencies. system cannot find file specified. source error: an unhandled exception generated during execution of current web request. information regarding origin , location of exception can identified using exception stack trace below. assembly load trace: following information can helpful determine why assembly 'system.web.webpages.deployment, version=3.0.0.0, culture=neutral, publickey...

why is my for loop function in r not working (trying to truncate outliers in the dataset) -

i'm trying replace extreme values nearest value in dataset. know ifelse () works better, wondering why loop not working. truncate <- function(a){ m <- mean(a) sd <- sd(a) <- m+3*sd low <- m-3*sd a1 <- c() (i in 1:length(a)){ if (a[i] > up) { a1[i] = } if (a[i] < low){ a1[i] = low } else { a1[i] = a[i] } } return (a1) } <- c(1:100) the for-loop working correctly , iterating through elements of 1:length(a) . assuming giving a <- c(1:100) input truncate() , function isn't working because returns same value a . seems because, using a input, up results in 137.5345 , low results in -36.53448 . no values greater up or less low , else statement reached. also, copy-and-append pattern using generate a1 in for-loop , conditional statements computationally expensive. can vectorized , function can made more efficient follows: truncate <- function(a) { m ...

android - NullPointer exception on Adding TextView on onDraw -

i'm trying add textview in ondraw method of mycustomview class. so, if works without issue, tv = new textview(context); tv.settextsize(14); tv.layout(left, top, right, bottom); tv.setgravity(gravity.center); tv.settext(text); canvas.save(); canvas.translate(left, top); tv.draw(canvas); but don't want instantiate textview in ondraw. if initialize textview outside (of ondraw), in class constructor example, code work. gives me following error, java.lang.nullpointerexception: attempt read field 'int android.view.viewgroup$layoutparams.width' on null object reference @ android.widget.textview.checkforrelayout(textview.java:8447) @ android.widget.textview.settext(textview.java:5378) @ android.widget.textview.settext(textview...

HTML text align in div -

Image
.test { background-color: red; text-align: center; } <div class="test"> this<br>is<br>a<br>test! </div> i use above code align text in middle of div. code works good, however, there way make appear on middle of div still 1 letter appear above other? example: wrap text in element, , center element. centered element keep default text-align: left . for example: .test { background-color: red; } .test div { margin: 0 auto; width: 28px; } <div class="test"> <div>this<br>is<br>a<br>test!</div> </div> or this: .test { background-color: red; display: flex; justify-content: center; } <div class="test"> <div>this<br>is<br>a<br>test!</div> </div>

How can I create a Wordpress website that does this kind of image processing -

Image
i beginner in web development , want guide me on this. know how build basic wordpress website. want functionality on wordpress site take text , image provided user , process make final image shown below : i have no idea how it. if guide me how achieve this, mean kind of tools need or reference guide help. thank reading :) take php librairie named gd. can create image, add text, colors , add existing image (your user image). there lot of tutorials librairie on internet.

javascript - Edit Field not working & Managing form values using redux store - redux-form -

i using redux-form v6.7.0 . referred link , tried load data asynchronously on button click not working expected. used change method in componentwillreceiveprops after using unable edit field . i don't know using change method , appropriate way of managing redux-form . pfb sample code snippet loaded personname using change method in componentwillreceiveprops , after unable edit field . personage , field working fine didn't used change method it. also, wanted synchronize changed form values redux store (means keep each , every change updated redux store). any appreciated. in advance. /* reducers should maintain immutability */ function personinforeducer(state = { personname: "", personage: "" }, action) { switch (action.type) { case "save_person_data": return object.assign({}, state, action.payload); default: return state; } } /* save person data action */ var savepersondata = (data) =>...

excel vba - I am unable to add Data Field to my Pivot Table VBA -

i runtime error unable pivottables property of worksheet class when run following code: sub updatepivot() dim ws worksheet, srcdata string, pvtcache pivotcache dim ws2 worksheet, nr long, nc long, ws3 worksheet dim pf pivotfield, pt pivottable, df pivotfield, str string 'set ws = thisworkbook.worksheets("lisun data") set ws2 = thisworkbook.worksheets("cover") set ws3 = thisworkbook.worksheets("stockist") set pt = ws3.pivottables("pivottable3") set pt = ws3.pivottables("pivottable3") pt.pivotfields(" may-17") .orientation = xlcolumnfield .function = xlsum .position = 1 end end sub may know wrong? i did add data source data model beforehand, , i'm not sure causing error. try code below try , trap errors, explanations inside code's comments: option explicit sub updatepivot() dim ws worksheet, srcdata string, pvtcache pivotcache dim ws2 worksheet, nr long, nc long, ws3 work...

php - Codeigniter CRUD app: error updating a record (trying to get property of non-object) -

i have put crud application codeigniter 3. update form has data validation set up, through controller: update function : public function update($customer_id) { // data validation $this->form_validation->set_rules('first_name', 'first name', 'required'); $this->form_validation->set_rules('last_name', 'last name', 'required'); $this->form_validation->set_rules('email', 'email address', 'required|valid_email'); $this->form_validation->set_error_delimiters('<p class="error">', '</p>'); if ($this->form_validation->run()) { $data = [ // insert these database table fields 'first_name' => $this->input->post('first_name'), 'last_name' => $this->input->post('last_name'), 'email' =>...

Does Python have a ternary conditional operator? -

if python not have ternary conditional operator, possible simulate 1 using other language constructs? yes, added in version 2.5. syntax is: a if condition else b first condition evaluated, either a or b returned based on boolean value of condition if condition evaluates true a returned, else b returned. for example: >>> 'true' if true else 'false' 'true' >>> 'true' if false else 'false' 'false' keep in mind it's frowned upon pythonistas several reasons: the order of arguments different many other languages (such c, ruby, java, etc.), may lead bugs when people unfamiliar python's "surprising" behaviour use (they may reverse order). some find "unwieldy", since goes contrary normal flow of thought (thinking of condition first , effects). stylistic reasons. if you're having trouble remembering order, remember if read out loud, (almost) mean. example, x...

not show result details mysql in jquery -

the below code html code: <input type="search" name="srchtxt" id="srchtxt"/> <div class="resultsearch"> <ul class="ul"></ul> </div> <a href="#" id="srchbtn"></a> and below code jquery code: $("#srchtxt").keyup(function(){ var addresshome = $("#srchtxt").val(); $.post("addressfile",{address:addresshome},function(res){ $(".ul").html(res); }); }); $(".ul li#item a").each(function(){ $(this).click(function(e){ e.preventdefault(); var index_address,address; index_address = $(this).parent().index(); alert(index_address); address = $(this).eq(index_address).attr("value"); $("#srchtxt").attr("value",address); }); }); $("#srchbtn").click(function(){ alert($("#srchtxt").val()); }); and below...

DataTables row details in Ruby on Rails - how to separate HTML from Javascript -

i using datatables jquery plugin in ruby on rails project (directly, not through datatables-rails gem) , need display row details explained here: https://datatables.net/examples/server_side/row_details.html in case, after calling $("#table_id").datatable() , use format() function in .js file pass data display row.child : /* formatting function row details */ function format(d) { // `d` original data object row return '<table cellpadding="5" cellspacing="0" border="0" style="padding-left:50px;">' + '<tr>' + '<td>' + label_variable1 + ':</td>' + '<td>' + d.office.name + '</td>' + '</tr>' + '<tr>' + '<td>' + label_variable2 + ':</td>' + '<td>' + d.office.location + '</td>' + '</tr>'...

javascript - Sort array, but ignore some specific characters in the beginning -

i have array elements being strings. , want sort them alphabetically, know should use sort() function. want happen ignore first few characters based on are. for example, if there array ['<file> dogs', '<dir> more', '<file> cats'] , how make ignore text <file> , , , sort these strings text comes after them? have create custom sorting function? you strip tags, answer , , take rest string sortable result. var array = ['<file> dogs', '<dir> more', '<file> cats']; array.sort(function (a, b) { function getraw(s) { return s.replace(/<(?:.|\n)*?>/gm, '').trim(); } return getraw(a).localecompare(getraw(b)); }); console.log(array);

c# 4.0 - I can not get values form RadioButtonFor List in asp.net mvc -

Image
i working on project have view different layout on mobile view , desktop view. solution creating on view 2 tables define different elements each view. bind data same model. please take @ code below: view <table class="pc" style="border: 1px solid #eeecdc"> <tbody> <tr> <td> @html.radiobuttonfor(m => model.selectedoption, 1) </td> <td> @html.radiobuttonfor(m => model.selectedoption, 2) </td> </tr> </tbody> </table> <table class="mb" style="border: 1px solid #eeecdc"> <tbody> <tr> <td> @html.radiobuttonfor(m => model.selectedoption, 1, new { @name = "selectedoption_mb" }) </td> <td> @html.radiobuttonfor(m => model.selectedoption, 2, new { @name = "selectedoption_mb" }) </td> </tr> </tbody> <...

android - unresolvable symbols as variables assigned to the widgets -

in following code snippet, field , buttonclickhandler both highlighted red, , selecting + holding alt + hitting enter not resolve it. i have widgets in layout xml file, wonder missing here? doing wrong? package com.example.me.android; import ... public class mainactivity extends appcompatactivity { // variables assigned widgets. // protected button _button; protected textview _field; protected imageview _image; // path , filename of photo. // protected string _path; // gets set 'true' once photo has been taken. // protected boolean _taken; // variable used key determining whether or not photo taken. // protected static final string photo_taken = "photo_taken"; @override protected void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r.layout.activity_main); // take picture , correct rotation. // _butto...

Javascript - Dynamic Function Call -

how below return value? var data = sql.execute({query:"select * profile_user"}).then(function (result){ return result; // actual result = [{id:1, name:"mr. test"}] }, function( err ) { console.log( "something bad happened:", err ); }); console.log("received data"+json.stringify(data)); result in console : received data{"_handler":{"resolved":false}} as answered above - function returns promise, result defined when promise resolved (or not defened if promise failed). the best practice here build async program way, when code, requires result placed on result/reject promise callbacks: var data = sql.execute({query:"select * profile_user"}).then(function (result){ console.log("received data"+json.stringify(data)); // doing data }, function( err ) { console.log( "something bad happened:", err ); }); if need ...

javascript - AngularJS ng-repeat and bootstrap to display items in colums from DB -

i'm trying adapt template mean app, , want display info load db in 3 columns. problem is, when using ng-repeat, displays data in 1 column. this code: <div class="row mt-5"> <div ng-repeat="woman in women"> <div class= "col-md-4"> <!--card--> <div class="card"> <!--card image--> <img class="img-fluid" src="{{woman.image_url}}" alt="{{woman.name}}"> <!--card content--> <div class="card-body"> <!--title--> <h4 class="card-title">{{woman.name}}</h4> <!--text--> <p class="card-text"> <h5>{{woman.field}}</h5> <br> {{woman.job}}</p> <a href="#!/women/details/{{woman._id}}" class="btn btn-prim...

excel - How to delete data from a XLSX file while keeping formatting in R -

i have 3 xlsx files 7 sheets each. each morning have delete contents of each sheet prepare importing new data. i want automate process using r. can excel macro, r script want (that way don't need wait longer macro enabled files way slower). i want blank sheets while keeping sheetnames, , formatting (i have formatted cells text, , cells have particular widths). solutions using openxlsx package more appreciated. edit: the sheets contain 15 columns , @ max 200 rows. still non vectorized solutions bit slow. this seems bit of hack, can write empty string each cell in use , save resulting workbook. library(openxlsx) wb = loadworkbook("test.xlsx") for(ss in 1:length(wb$worksheets)) { rows = wb$worksheets[[ss]]$sheet_data$rows cols = wb$worksheets[[ss]]$sheet_data$cols for(i in 1:length(rows)) { writedata(wb,ss,"", startcol = cols[i], startrow = rows[i]) } } saveworkbook(wb, "test2.xlsx", overwrite = true) ...

javascript - ajax and jquery, can send data to sever but not receive it -

i'm extremely new ajax/node/jquery please excuse rookie errors. i'm trying send data node server , update page response using jquery, can send data server unable response. sure success method not firing never receive alert. so, aim on clicking size_button , contents of size_form sent server. finished item process contents of size_form example sending server , updating response required. jquery code: $(document).ready(function() { $('#size_button').click(function(e){ $('#response').html("searching size..."); var url = "http://localhost:8081/search_size"; // script handle form input. $.ajax({ type: "post", crossdomain: true, url: url, data: $("#size_form").serialize(), // serializes form's elements. //data: $('#size_form'); success: function(data) { alert(data); // show response php script. $('#response').html(data); ...

Comparing input values with csv file in Python 3.4 -

i've got simple question can't find right solution that. i have csv file contains students' names , subjects registered: name,subject1,subject2,subject3 student1,mn1,mn2,mn3 student2,bn1,bn2,bn3 student3,mn4,mn5,mn6 student needs enter name , subject name in order check whether registered or not subject my code: import csv name = input("please provide name: ") subject = input("please provide subject: ") open('students.csv') csvfile: reader = csv.dictreader(csvfile) row in reader: if (row['name'] == name , row['subject1'] == subject or row['subject2'] == subject or row['subject3'] == subject): print ("you registered. won't take long run vm") else: print ("you not registered") my problem gives multiple outputs me output: please provide name: student3 please provide subject: mn4 not registered not registered registered. won't ...

kinect - How to use SendKeys. Send("UP") to sending "up" arrow key to applications except notepad? -

i using line code under detail arrow key type "up" in notepad sendkeys.send("up"); this working in notepad process need use above line code in application except notepad games i had guess notepad process should change process work on not , not work in game process suggestion can useful

javascript - Radio button to switch between variables in a JS function -

i have 2 options (same api request, different urls) i'd use switch button (radio) let user choose type of results: function apirequest() { var mydata = document.getelementbyid('userinput').value; var userapi = document.getelementbyid('userapi').value; var userurl = document.getelementbyid('userurl').value; $.post( myurl, json.stringify({ 'api_key': userapi, 'data': mydata, })).then(function(sent) { var s = sent var obj = json.parse(s) $('.score').text("score : " + obj.results*100) }); } html <input class="search-field" type="text" placeholder="i love writing code!" id="userinput"> <input class="search-field" type="text" placeholder="1234567890" id="userapi"> <div class="material-switch pull-right" style="padding-left: 25px"> <input id=...