Posts

javascript - Validate a form in AngularJS -

Image
i working on angularjs form validation. below form i have 3 variables toolid , timeremaining , maxqtyobj in javascript file , want validate form fields " tool id " , " time remaining " 2 variables i.e. field toold id should equal variable toolid & field time remaining should less variable timeremaining. and show alert when user enter values qty fields greater value stored in maxqtyobj contains sx & qty. if user clicks on yes, proceed or else cancel process. please help. i solved problem using ng-blur attribute. on ng-blur of elements defined function , set boolean values variables inside these function. if true proceed in ng-click of defined function.

Swift CGRectMake Center button -

i'm programming button swift spriest project. location of button messing up. wan in middel goes random place. let button = uibutton(type: .system) // let preferred on var here button.frame = cgrectmake(self.frame.width / 2, self.frame.height / 2, 100, 50) print(self.frame.height / 2) button.backgroundcolor = uicolor.greencolor() button.settitle("button", forstate: uicontrolstate.normal) self.view!.addsubview(button) i don't know why cgpoint works can't use cgpoint here. try this... button.frame = cgrectmake( self.view.center.x - (widthofbutton / 2), self.view.center.y - (heightofbutton / 2), widthofbutton, heightofbutton)

python 2.7 - mapper_parsing_exception error when indexing pdf in elasticsearch -

i trying index pdf using elasticsearch 2.3.4 , python. want extract text , metadata pdf index. using mapper_attachment plugin. when trying index, getting 'mapper_parsing_exception'error. following code, #configuration dir = 'd:/qa_testing/testing/data' es_host = {"host" : "localhost", "port" : 9200} index_name = 'testing' type_name = 'documents' url = "d:/xyz.pdf" es = elasticsearch(hosts = [es_host]) mapping = { "mappings": { "documents": { "properties": { "cv": { "type": "attachment" } }}}} file64 = open(url, "rb").read().encode("base64") data_dict = {'cv': file64} data_dict = json.dumps(data_dict) res = es.indices.create(index = index_name, body = mapping) es.index(index = index_name, body = data_dict ,doc_type = "attachment", id=1) error: traceback (most recent call last): fi...

javascript - Open download windows using jQuery's each() -

i've got table containing several rows each row represents exportable file, e. g.: <tr> <th class="text-center" scope="row"> <input id="exportid-23" type="checkbox" /> </th> <td class="text-center text-nowrap">2016-08-24</td> <td>name</td> <td>city</td> <td class="text-center text-nowrap">person</td> </tr> [...] <button id="exports" class="btn btn-success" type="button"> <span class="glyphicon glyphicon-export"></span> export </button> in order return files requested upon user's click on export button, wrote this: $('#exports').click(function () { var exports = $(this); $('[id^=exportid-]').each(function () { if (this.checked) { window.open('ajax/get-exports.php?exportid=' + this.id.substring(9)); } }); }); ...

java - Searching for a '$' in a string -

how can make working. want check if string contains $ sign. if(messagesuccess.îndexof('$')>0) this error getting: no signature of method: java.lang.string.îndexof() applicable argument types: (java.lang.string) values: [$] thanks you invoking method not exist : îndexof() change indexof() , change î i

php - warning : creating default object from empty value in cakephp -

i working on cakephp 3.2 i have function find product types if exists if ($product['product_type'] != null) { $getproducttype = $this->producttypes->find() ->where(['title like' => '%'.$product['product_type'].'%']) ->first(); debug($product['product_type']); // not empty debug($getproducttype); // shows 'id' => 1 in array debug($getproducttype->id); // shows 1 if (!empty($getproducttype)) { $p->product_type_id = $getproducttype->id; // line 11 $p->subcategory_id = $getproducttype->subcategory_id; $p->category_id = $getproducttype->category_id; return $this->savenewbulkproduct($product, $p->category_id, $p->subcategory_id, $p->product_type_id); } } but giving warning as creating default object empty value on line 11 edit 2 output of print_r($getproducttype) app\model\entity\pro...

python - Django: Search Engine -

i trying make search engine of sorts in django, user enters query via form , gets output if query exists in database. here's code: urls.py: from django.conf.urls import url django.contrib import admin search import views urlpatterns = [ url(r'^admin/', admin.site.urls), url(r'^', views.form), url(r'^search/', views.data,name='search'), ] models.py: from __future__ import unicode_literals abc import abcmeta django.db import models # create models here. class album(models.model): artist = models.charfield(max_length=100) album_title = models.charfield(max_length=100) genre = models.charfield(max_length=100) album_logo = models.charfield(max_length=100) def __str__(self): return self.album_title + "-" + self.artist views.py: from django.http import httpresponse,http404 models import album forms import formquery django.shortcuts import render django.template import loader . import * def dat...