w3hello.com logo
Home PHP C# C++ Android Java Javascript Python IOS SQL HTML videos Categories
How to programmatically select multiple options with Chosen.JS multiple select
I'm not sure this is the recommended way of doing it, but the solution which works for me is to manually change the selected="selected" attributes on the options and than trigger the "liszt:updated" event. To select first 3 options use the following code: $('select option:nth-child(1)').attr('selected', 'selected'); $('select option:nth-child(2)').attr('selected', 'selected'); $('select option:nth-child(3)').attr('selected', 'selected'); $('select').trigger('liszt:updated'); // since version 1.0 the event name is changed to $('select').trigger('chosen:updated');

Categories : Javascript

Won't display cities and similar on map
well...the center is just over the pacific ocean... try to make a map.setCenter() to the point. if (place.geometry.viewport) { map.fitBounds(place.geometry.viewport); } else { map.setCenter(place.geometry.location); map.setZoom(17); }

Categories : Javascript

How to display the nearest cities using any API?
Yes, it is quite simple using Google Geocoding and Geometry APIs: https://developers.google.com/maps/documentation/geocoding/ https://developers.google.com/maps/documentation/javascript/geometry

Categories : PHP

How to display the nearest cities using Google API?
This might be an alternative for you, Another option: Download the cities database from http://download.geonames.org/export/dump/ Add each city as a lat/long -> City mapping to a spatial index such as an R-Tree (some DBs also have the functionality) Use nearest-neighbour search to find the closest city for any given point Advantages: Does not depend on aa external server to be available Very fast (easily does thousands of lookups per second) Disadvantages: Not automatically up to date Requires extra code if you want to distinguish the case where the nearest city is dozens of miles away May give weird results near the poles and the international date line (though there aren't any cities in those places anyway

Categories : PHP

Organize States and Cities and display certain way PHP
if ($fstate != $prev) { echo "<tr>$fstate</tr><tr>"; You're producing a badly-formatted table. If your table contents aren't inside <td> or <th> tags, when it's rendered, they appear in the wrong place. Try this: if ($fstate != $prev) { echo "<tr><th>$fstate</th></tr><tr>";

Categories : PHP

How should I works with countries and cities in MongoDB
Depending on how your intending to query for ads keeping it as you have it may be alright. With the schema presently as such you can perform a query like so (nodejs example): orm.Ad.find({city:"New York"}).exec(function(error, ads) { }); This will return all ads containing 'New York' as the city. I don't see any reason from what you have said to have separate collections for known cities and countries. Edit: When storing data in mongo a unique id is created for the item. You don't have to do this. If you were to query for all ads for city AND country you could modify your query as such: orm.Ad.find({$and: city:"New York", country:"united states"}).exec(function(error, ads) { });

Categories : Mongodb

get list of cities to show in a web page
Maxmind may be of use Or you could convert the data to xml and then use that, there are tools available. It is then possible to convert xml to sql but the actual implementation would depend on which language and database is your preference.

Categories : PHP

Jquery multiple select (ctrl click) to multiple select (single click)
Try this. <SELECT multiple> - how to allow only one item selected? Working example: http://jsbin.com/odicu4

Categories : Jquery

How can I better place cities around procedurally generated terrain?
I would lower the constrains for possible city-locations. Calculate a probability for each position for a city. Than set a city by random according to the probabilities of all locations not yet occupied by cities. Than lower the probabilities around the new set city (within a certain radius, Near the city lower the probabilities a lot (or even set them ti 0) and only lower then less with increasing distance. This way the cities should be spread around your terrain quite naturally. Example (very little one) How to take the next location: You have 3 possible locations with probabilities 0.9, 0,2 and 0.4 Now sum up the probabilities 0.9 + 0.2 + 0.4 = 1.5 now take a random number between 0 and 1.5. 0 .. 0.9 take the first location 0.9 .. 1.1 take the second location 1.1 .. 1.5 tak

Categories : Algorithm

jquery multiple select making ajax load when prior select has been enumerated
You could use callbacks, deferreds, or promises. You could even synchronize the jQuery's AJAX by turning async to false (It will default to true). If you want to stick with jQuery async, then I'd suggest taking a look here: http://api.jquery.com/promise/ From the examples: var div = $( "<div />" ); div.promise().done(function( arg1 ) { // will fire right away and alert "true" alert( this === div && arg1 === div ); });

Categories : Jquery

Remove last selected element from the multiple select if user select more than 3 option using jquery
This works quite nicely: var lastSelected; $("#testbox").change(function() { var countSelected = $(this).find("option:selected").length; if (countSelected > 3) { $(this).find("option[value='" + lastSelected + "']").removeAttr("selected"); } }); $("#testbox option").click(function() { lastSelected = this.value; }); I had to set a global variable lastSelected as well as an options click event to capture the actual last option clicked (this.value in the change event was giving me the top selected option, not the actual last option). Demo: http://jsfiddle.net/JAysB/1/

Categories : Javascript

get distinct list of cities from Active Directory via ldap
you need to perform a paged search operation to return more data than the default 1000 limit per query. Paged search works so that it still gets 1000 items per query but the server remembers where your search stopped, sends you a cookie and you can use this cookie later for subsequent search requests. The server will then return another 1000 items, and so on, until the server returns empty cookie -> the resultset is complete. This usually takes some amount of code to get all things right. I would recommend that if you plan to do more with ldap take a look at some well-established libraries for php, like adLDAP or AD-X. As for the search query itself, I recommend going the following way: You perform a search for all users who have the l attribute filled in: (&(objectcategory=person)

Categories : PHP

In ZF2 where i have to declare common arrays (Countries , cities , pincode , etc ... )
It would make a lot of sense to create classes for those and use Dependency Injection for injecting into controllers / models / view helpers. You can inject into your controllers and view helpers in Module.php Reason to wrap your arrays in classes: at the moment you might have hard-coded arrays, but what if in the future you will store those in a file/database/memcached. This article on DI will be very helpful: http://www.zfdaily.com/2012/07/getting-dependencies-into-zf2-controllers/

Categories : Arrays

How to avoid getting different city in return value for zipcodes shared by 2 cities
I guess I'll expand my comment into a (partial) answer. I don't know how to use Google's API to return the city name you want. But maybe this will still be helpful. (I work at SmartyStreets, where US addresses are our specialty.) First, let's look at that ZIP code: 53227. According to a SmartyStreets lookup, it is indeed valid and its Post Office (preferred) city name is Milwaukee. West Allis is a suburb which shares the zone, so you're correct there. Now on to the actual address. As mentioned in my comment, Google doesn't verify addresses, but rather standardizes them, and puts them on a map where they would exist if they were real. This has many useful applications, but if you're looking for validation, you need a true address validation service. Looking that address up with the homepa

Categories : Google Maps

Does MySQL "SELECT LIMIT 1" with multiple records select first record from the top?
It just gets one at random*. There's no way to tell which one it will be, unless you add an ORDER BY clause. * Not really at random, of course. It depends on the way the records are stored and repeated queries will probably return the same result every time, at least as long as you don't modify the table or its contents. I actually mean, you cannot be sure.

Categories : Mysql

When select one option from "multiple select", remove it from other selects (and reverse)
basically you want to remove the option via JS/jQuery and the update the plugin. Here is some code $(".chzn-select").change(function(){ $(".chzn-select") .not($(this)) .find("option[value="+$(this).val()+"]") .remove(); $(".chzn-select").trigger("liszt:updated"); }); and a fiddle link JsFiddle EDIT: try this new fiddle it handles multiple select $(".chzn-select").css('width', '300px').chosen({ display_selected_options: false, no_results_text: 'not found', }).change(function(){ var me = $(this); $(".chzn-container .search-choice").each(function(){ var text = $('span',this).text(); $(".chzn-select") .not(me) .find("option").each(function(){ if (

Categories : Javascript

Single SELECT with linked server makes multiple SELECT by ID
What you see may well be the optimal solution, as you have no filter statements that could be used to limit the number of rows returned from the remote server. When you execute a query that draws data from two or more servers, the query optimizer has to decide what to do: pull a lot of data to the requesting server and do the joins there, or somehow send parts of the query to the linked server for evaluation? Depending on the filters and the availability or quality of the statistics on both servers, the optimizer may pick different operations for the join (merge or nested loop). In your case, it has decided that the local table has fewer rows than the target and requests the target row that correspons to each of the local rows. This behavior and ways to improve performance are describe

Categories : SQL

How to SELECT DISTINCT on multiple cols AND select other colums in mysql
You want to use group by instead: SELECT a, b, c FROM mytable group by a, b; Distinct works on all the columns, not just a few. This formulation returns an arbitrary value of c from one of the rows. More typically, you would choose a value, such as: SELECT a, b, min(c) FROM mytable group by a, b;

Categories : Mysql

Minimun cost to visit only selected cities and come back to start?
I don't have my code handy, but here's some suggestions and pseudocode to get you going: I would solve this by storing a vector as well as your above distance matrix in memory. Something like: struct Location{ bool visited; bool mustVisit; } Vector<Location> locationVec; Populate the vector with the locations in your problem, marking whether or not they have to be visited, and always setting visited to false. Then comes the fun part! You need to create permutations of the locationVec. I would do this recursively, something like: void addLocation(int & curLength, int & maxLength, int & curDistance, Vector<Location> &locationVec, Location* lastVisited) if(curLenth == maxLength){ //check if currentDistance is less than the previously generated best differe

Categories : C++

Drawing districts of large cities using google maps or openstreetmaps APIs
Is it feasible to build a map using the google maps API or Openstreetmaps which has a superimposed layer that displays districts of a city? It is possible. Feasible is up to you. I generated this map at OpenStreetMap.org. Where would one obtain the data for these regions (worldwide)? Photoshop would be one place to start.

Categories : Google Maps

change the select criteria according to a multiple select
Use SQL IN to avoid your situation. Something like this: // this is crude way to create your SQL IN part // Ideally you should be iterating over your selections and creating this string String selections = firstSelection + "," + secondSelection; select * from myTable where x IN(selections);

Categories : Java

Sql select by multiple values from select with many joins
You could try to execute the main query in a WITH [...] AS and then the join. Maybe it's faster: WITH t AS ( SELECT Value FROM DVPST WHERE ValueStr IN ("value1", "value2", ..., "value1000") ) SELECT dv.Id, dv.Version, cvco.Time FROM t INNER JOIN DVPCT dvpc ON t.Value = dvpc.Value INNER JOIN DVPT dvp ON dvpc.Id = dvp.Id INNER JOIN DVT dv ON dvp.Id = dv.Id INNER JOIN CVCOT cvco ON dv.Id = cvco.Id INNER JOIN DT doc ON doc.Id = dv.Id Or try with #tempTable (it can be faster in certain cases): SELECT Value INTO #table FROM DVPST WHERE ValueStr IN ("value1", "value2", ..., "value1000") SELECT dv.Id, dv.Version, cvco.Time FROM #table t INNER JOIN DVPCT dvpc ON t.Value = dvpc.Value INNER JOIN DVPT dvp ON dvpc.Id = dvp.Id

Categories : SQL

bootstrap select picker multiple select
in case you haven't solved this in a month :S. I think the reason why it doesn't show the selected items after the document loads is because you are calling selectpicker initializer two times when you should call it once. You just have to populate your select as you would normally and just call the selectpicker inside the document.ready. For example: In my JSP, I have a multiple select to choose days of the week which I pass through the servlet using an array, and I want some of them to be selected: <select class="selectpicker" multiple name="dayGroup" title="Select days"> <c:forEach var="weekDay" items="${weekDays}"> <option value="${weekDay}" ${fn:contains(days, weekDay) ?'selected' : ''}>${weekDay}</option> </c:forEach> </select> Where weekDa

Categories : Javascript

T-SQL - How to Select and Group Multiple Records (in multiple columns) for Each Employee?
You can do this: SELECT t1.First_Name, t1.Last_Name, STUFF(( SELECT ', ' + t2.Address FROM Tablename AS t2 WHERE t1.First_Name = t2.First_name AND t1.Last_Name = t2.Last_Name FOR XML PATH('')) ,1,2,'') AS Address FROM tablename AS t1 GROUP BY t1.First_Name, t1.Last_Name; This will give you the results grouped by First_name and Last_Name with the address coma separated. See it in action here: SQL Fiddle Demo This will give you: | FIRST_NAME | LAST_NAME | ADDRESS | ----------------------------------------------------- | Jim | Doe | 1111 Street, 2222 Street | | John | Smith | 5000 Street, 6666 Street |

Categories : SQL

error when set multiple variable values from multiple select queries
User var_dump($_POST); to see actual name of variables. Usrname and other indexes are simply not defined in post array. Use mysqli functions in php not mysql, because they already are deprecated, and they are not to be used in the future versions of php.

Categories : PHP

Javascript show multiple table rows from multiple select
I have fixed the problem myself, the solution was: $('table#newspaper-a tr:not(#header, #trWeekNummer)').hide(); if(List[x].selected) { $('table#newspaper-a tr:not(#header, #trWeekNummer)').each(function(){ $('td:nth-child(1)',this).each(function(){ if($(this).text() == List[x].value) $(this).parent(this).show(); }); }); }

Categories : Javascript

Select Single field multiple times with multiple criteria
Try something like this: SELECT Project ,sum(CASE WHEN Activity = 'Shearing' THEN [Surface Area] ELSE 0 END) AS TotalShearing ,sum(CASE WHEN Activity = 'Bending' THEN [Surface Area] ELSE 0 END) AS TotalBending ,sum(CASE WHEN Activity = 'Assembly' THEN [Surface Area] ELSE 0 END) AS TotalAssembly ,sum(CASE WHEN Activity = 'PC' THEN [Surface Area] ELSE 0 END) AS TotalPC ,sum(CASE WHEN Activity = 'Infill' THEN [Surface Area] ELSE 0 END) AS TotalInfill WHERE ([Posting Date] BETWEEN @StartDate AND @EndDate) FROM PLE GROUP BY Project SQLFiddle DEMO

Categories : SQL

SQL: how to select a single id that meets multiple criteria from multiple rows
You need to group by the package_id and then use having to perform an aggregate function over the grouped data select package_id from package_content where content_number = 22 or ( content_number = 11 and content_quality = 1 ) group by package_id having count(distinct content_number) = 2

Categories : Mysql

Select statement having multiple conditions over multiple columns
if you only want to check if there are rows that fulfill certain conditions you can use following construct select count(*) from dual where exists ( select 1 from myTable where (key = 'A' and value = 'V1') ) AND exists ( select 1 from myTable where (key = 'B' and value = 'V2') );

Categories : SQL

how to set multiple option value in multiple select box after refresh the page
I'm not sure how your data is populated and presented, but here's an example: <?foreach($selects as $select):?> <?$selected = ($select->Selected === true) ? 'selected="selected"' :'';?> <select id="<?=$select->Id?>" name="<?=$select->Name?>"/> <?foreach($select->Options as $option):?> <option value="<?=$option->Value?>"<?=$selected;?>><?=$option->Text?></option> <?endforeach;?> <?endforeach;?> Or foreach($selects as $select) { $selected = ($select->Selected === true) ? 'selected="selected"' :''; echo "<select id="{$select->Id}" name="{$select->Name}"/> "; foreach($select->Options as $option) { echo "<option value="{$option->Value}"{$selected}>{$

Categories : PHP

Using VBA, how can I select multiple rows, on multiple worksheets for printing?
I believe that the only way to use .select on a range is to have the worksheet "active". This should answer your question, but I think you've complicated things for yourself. . . Else .Activate ' new line .Select (False) .Rows.Select End If . . In Excel macros, I try to avoid using .select and instead refer to ranges directly. For instance if I want to copy values from one range to another it would be something like: Worksheets(2).Range("A1").Value = Worksheets(1).Range("A1").Value Also, looks like you're looping through the sheets by index number, starting at the second one until you get to ListCount. Be aware that the sheet index changes based on tab order. You may be better off looping through all worksheets in the workbook with a "For Each" loop and comparing

Categories : Excel

Select multiple items across multiple tables with join
First, note that when you call AsEnumerable the query must be executed on the client, rather than on the SQL server. I'd strongly recommend leaving the tables as IQueryable's to avoid this. Next, as Tim S. explains, since your tables are not strongly typed, use the Field<T> method to retrieve the column value. Finally, if you want to return multiple columns, you'll need to group the results into an anonymous type: var query = from l in DbConfig.Tables["table2"] join s in DbConfig.Tables["table1"] on l.Field<string>("itemB") equals s.Field<string>("item1") where l.Field<string>("itemA") == name select new { item = s.Field<string>("item"), item2 = s.Field<string>("item2")

Categories : C#

Select One Active Image from multiple Multiple Images
what about this <input type="file" name="images[]" /> <input type="hidden" name="active[]" value="0" class="active" /> <input type="radio" name="activeImage[]" onclick="$('.active').val(0);$(this).prev().val(1)" value="1" /> Now when you dump the data in php you have to active the image based on the index in post array like [active] => Array ( [0] => 0 [1] => 1 [2] => 0 ) So you know that active[1] contains value 1 so second image is selected by user , so make active second image in the $_FILES array Hope you got my idea

Categories : PHP

SELECT multiple values to the same key in multiple tables
You should try SELECT t1.uid FROM tabl_1 t1 INNER JOIN tabl_2 t2 ON t1.uid = t2.uid AND t2.meta_key = 'location' AND t2.meta_value = 'NY' INNER JOIN tabl_2 t3 ON t1.uid = t3.uid AND t3.meta_key = 'school' AND t3.meta_value = 'NYU' Check result on http://sqlfiddle.com/#!2/f35ef/1/0

Categories : Mysql

Select Multiple column from multiple table and every two tables have an idenetity column
I think you would just change this line: where TAG.loginName ='kmg' To: where TAG.loginName = @LoginName And then you would call it by using: EXEC uspGetApplicationsByLoginName 'kmg'

Categories : Sql Server

SQL SELECT multiple authors?
Take a Look at this question basically you're going to need: WHERE posts.post_author IN ($author)

Categories : SQL

Select multiple tag values of xml in sql
You can use OPENXML for that: DECLARE @nDoc int DECLARE @xml xml SET @xml = '<parameter_set> <parameter> <name>device_index</name> <type>1</type> <state>1</state> <value>1</value> </parameter> <parameter> <name>trx_index</name> <type>1</type> <state>1</state> <value>3</value> </parameter> </parameter_set>' EXEC sp_xml_preparedocument @nDoc OUTPUT, @xml SELECT * FROM OPENXML(@nDoc, '/parameter_set/parameter', 1) WITH( name nvarchar(MAX) 'name', value nvarchar(MAX) 'value' ) EXEC sp_xml_removedocument @nDoc

Categories : Sql Server

How would I select a name tag with multiple [] in jquery?
Try something like $('input[name="web[3][feld]"]').attr('checked', true); You need to mention input tag before you are checking for the name See the working FIDDLE

Categories : Jquery

Select multiple countries on a map
You can do this fairly easily with Google's Data Visualization Geocharts. Just initialize your Geochart. You need to pass in a DataTable for the chart to draw, so just pass in an empty DataTable without any row data. var data = google.visualization.arrayToDataTable([ ['Countries'] ]); var options = { //set any options you want to the chart }; var chart = new google.visualization.GeoChart(document.getElementById('chart_div')); chart.draw(data, options); Then listen for click events on the regions, using the 'regionClick' event and you can append this to a list or handle the selected region data however you want. But this should provide a good starting point for country selections via a graphical map. google.visualization.events.addListener(c

Categories : Javascript

select top value from multiple values
A good solution is; SELECT user_id, SUM(IF(desc='credit',-1,1)*amt) AS balance FROM trans GROUP BY user_id Your suggested table is not well designed. You should really not store the balance for each row, as that can introduce inconsistency in your data. What happens if the individual amt don't agree with the bal fields? Store just the amt fields. It would be simpler if you dropped the desc column and stored credits as negative. In that case, you just select SUM(amt) AS balance.

Categories : PHP



© Copyright 2017 w3hello.com Publishing Limited. All rights reserved.