w3hello.com logo
Home PHP C# C++ Android Java Javascript Python IOS SQL HTML Categories
Angularjs: ng-options with group
The grouping doesn't quite work like that, if you change your json to something like this: [ {"ID":"1", "TIPIS":"GroupName1", "DESC":"name"}, {"ID":"2", "TIPIS":"GroupName1", "DESC":"name1"}, {"ID":"3", "TIPIS":"GroupName2", "DESC":"name2"}, {"ID":"4", "TIPIS":"GroupName1", "DESC":"name3"}, ] Then you'll get the grouping the way you want jsFiddle: http://jsfiddle.net/rtCP3/182/

Categories : Angularjs

AngularJs and
Angular overrides the "selected" property when you bind the select to a model. If you inspect the rendered DOM you will find that a new item has been added: <option value="? undefined:undefined ?"></option> In order to automatically select the third option you need to pre-populate the model in scope. There are a few ways to do this, including wrapping the select in a controller: <div ng-controller="MyCtrl"> <select id="myselection" ng-model="selectedColors"> <option value="1">Red</option> <option value="2">Blue</option> <option value="3">Green</option> </select> <div>Selected Colors: {{selectedColors }}</div> And then defining that model in the controller. var myApp = angula

Categories : Angularjs

Multiple selects which disable each other's options
var previous = -1; // Setting a previously selected value $("select").change(function () { // When any select element is changed if ($(this).val() > -1) { // When value is > -1 // Get all selects but not the current one which triggered the change event $("select").not(this) .find("option[value=" + $(this).val() + "]").attr('disabled', 'disabled'); // set the current option value to disabled // Get all selects but not the current one which triggered the change event $("select").not(this) .find("option[value=" + previous + "]").removeAttr('disabled'); // Remove the disabled property on previous value } else { // Get all selects but not the current one which triggered the change event $(

Categories : Jquery

Is this the way to go for storing options from a dropdown with multiple selects?
This is generally considered poor database design. It makes it hard to add new options, since you have to update the database schema, and change all applications to know about this new column. A better solution is an options table with columns option_id and option_name. Then you use a reference table user_options with columns user_id and option_id to link them.

Categories : Mysql

Setting up the options for a series of dynamic selects
As per the documentation, it should be o for o in question.options Note that you'll need to specify an ng-model attribute for this to work: <select ng-model="question.selectedOption" ng-options="o for o in question.options"></select> Here's a plunk showing that it works.

Categories : Angularjs

How to add select menu options to multiple selects using javascript
Try this See Reference For Array $.each(selectValues, function(key, value) { $('#mySelect').append($("<option/>", { value: key, text: value })); }); For List JQuery var list = $("#selectList"); $.each(items, function(index, item) { list.append(new Option(item.text, item.value)); }); JavaScript var list = document.getElementById("selectList"); for(var i in items) { list.add(new Option(items[i].text, items[i].value)); }

Categories : Javascript

Getting the number of selects with no option selected
Off of the top of my head, I think this will work: $('select.fabricColorSelect option[value=""]:checked').size() (yes, I meant :checked)

Categories : Javascript

Show options of selected options inside the same
If you are looking for a tree view layout using jquery, try this code: $('.tree li').each(function(){ if($(this).children('ul').length > 0){ $(this).addClass('parent'); } }); $('.tree li.parent > a').click(function(){ $(this).parent().toggleClass('active'); $(this).parent().children('ul').slideToggle('fast'); }); Demo and Source: http://www.webstutorial.com/jquery-treeview-list/jquery

Categories : Jquery

asp.net mvc listbox options are selected even though selected value is not defined
Options are already selected because they are reflecting the state of your model. This line @Html.ListBoxFor(model => model.AvailableProducts tells ASP.NET MVC to bind the property model.AvailableProducts to the list box. Since this property contains all four options presented in the list, they all are selected by default. You can comment out code that fills this list and verify that none of the options are selected. If you really want just a list box with options that will add specific parameter with name AvailableProducts to the request, you can use Html.ListBox: @Html.ListBox("AvailableProducts", new MultiSelectList(Options , "Key", "Value"), new { size = "6" })

Categories : C#

Can I render many options with selected="selected" using f:selectItem?
When talking in JSF context, you normally do that by setting the <h:selectManyListbox value> to the desired value beforehand, like as you would do for every other JSF UIInput component in order to preset/preselect the value. The desired HTML output can be achieved with this view <h:selectManyListbox id="example-presets" value="#{bean.selectedItems}" size="5"> <f:selectItems value="#{bean.availableItems}" /> </h:selectManyListbox> and this model in #{bean} private List<String> selectedItems; // +getter+setter private List<SelectItem> availableItems; // +getter (no setter necessary) @PostConstruct public void init() { selectedItems = Arrays.asList("option1", "option3", "option4"); availableItems = Arrays.asList( new SelectItem("op

Categories : Jquery

How do I properly index a query that selects multiple fields when using GROUP BY and ORDER BY?
Here is an idea. Create an index on emails(created, batchid) and another on emails(batchid). Now do: select e.id, e.batch_id, e.user_id, e.subject, e.send_date, e.created from (select batchid, created from emails order by created desc limit 10 ) e10 join emails e on e.batchid = e10.batchid group by e.batchid order by created desc; The idea is to reduce the set you are processing, before doing the aggregation and ordering. It also sounds like your data would be better if it were more normalized. One table should have the batch information, including the sender and created date. The other should have

Categories : Mysql

Collapse all group except selected group in expandable listview android
Use this code this will work expandableList.setOnGroupExpandListener(new OnGroupExpandListener() { int previousItem = -1; @Override public void onGroupExpand(int groupPosition) { if(groupPosition != previousItem ) expandableList.collapseGroup(previousItem ); previousItem = groupPosition; } });

Categories : Android

Need help creating a second drop down box of options based on what a user selects in the first drop down box
Have you ever heard of JQuery. If not, it time for some education. Among a host of other things, JQuery makes it fairly easy to simpllify your AJAX calls -- Best time I ever invested in web development was learning JQuery. See http://api.jquery.com/jQuery.ajax/ for the JQuery docs for the AJAX method. There are some simple usage examples at the bottom of the page. There are also plugins that handle cascading dropdowns lists with simple code, like this one http://jquery-plugins.net/jquery-cascading-dropdown-plugin Once you start using JQuery, you will discover the hardest thing is getting good lists of car makes and models -- hint they vary by model year too.

Categories : PHP

angularjs: nested ng-repeat creates blank values in selects
Since you use the n.id in the comprehension expression of the drop down list, you should pre-populate the offer.network with the id value like this network: $scope.networks[0].id And since the data is populated dynamically, you can do something like this. (For the demo purpose, I just use a very dumb way to populate the values. But you get the idea.) $scope.getNetworks().then(function(data){ $scope.networks = data; //populate the default value $scope.campaign.paths[0].offers[0].network = $scope.networks[0].id; $scope.campaign.paths[0].offers[1].network = $scope.networks[0].id; }) Working Demo

Categories : Javascript

Set an already existing selected attribute to the default selected value in a select box Angularjs
Thanks to Blackhole for pointing me in the direction of the answer: Angular compares for reference rather than for equality. All I had to do was find the index of the correct state in the states array and set the person.state object to reference THAT state object in the array. Now it works great! Thanks Blackhole for steering me in the right direction!

Categories : Javascript

Which is quicker in psql: 2 inserts from selects, or one insert from union of selects?
I'd say union all would be faster than two inserts, just because it's one transaction instead of two, but I'm not DBA at all, and I guess it could depend on number of rows / types of columns in the tables. Tested on SQL fiddle on PostgreSQL 9.2.4 on 2 table with 1 000 000 records each. Results: 2 inserts ~ 2600 ms 1 insert with union ~ 10800 ms - eliminating duplicates is expensive! 1 insert with union all ~ 2460 ms see it on sql fiddle demo

Categories : SQL

Set selected on options using PHP / JS
oh yes ofcourse there is an easy way. IN PHP $opts = array( 'CR01' => '...', 'CR02' => '...', .... ); <select name="siteid"> <?php foreach( $opts as $var => $opt ): ?> <option value="<?php echo $var ?>" <?php if( $var == $sid ): ?>selected="selected"<?php endif; ?> > <?php echo $opt ?> </option> <?php endforeach; ?> </select> IN JS VANILLA function setOption(selectElement, value) { var options = selectElement.options; for (var i = 0, optionsLength = options.length; i < optionsLength; i++) { if (options[i].value == value) { selectElement.selectedIndex = i; return true; } } return false; } setOption( document.querySelector('select[name='siteid']'), "&

Categories : PHP

jQuery selected options
$('select option[value="..."]').toggleOptionVisibility(false); $('select').val($('#select-test > option:first')); To get selected value : $('select option:selected').val() Example : http://jsfiddle.net/d3FuV/5/

Categories : Jquery

Get selected item with ng-options
I don't know if this is the best solution to your problem, but it works. What I ddid was to simply create a function to search for the chosen value set as true. Upon finding that value I set the scope model as that attribute value. Then I called that function immediately afterwards. $scope.selectChosen = function selectChosen() { var attrVals = $scope.profileData.attributes[0].attributeValues; for (var i = 0; i < attrVals.length; i++) { if (attrVals[i].chosen) { $scope.attributeValue = attrVals[i]; break; } } }; $scope.selectChosen(); The complete plunker is at: http://plnkr.co/edit/UcmQ8Q?p=preview

Categories : Angularjs

jquery selected options from one to another
You can get the selcted options using option:selected and append to other select using appendTo(). It will remove the options from first select automatically. Live Demo $('#p_prod option:selected').appendTo('#s_prod'); To revert you need to store indexes, and you would need some thing like this, Live Demo $('#change').click(function () { $('#p_prod option:selected').each(function () { $(this).data('prevIndex', $(this).index()); $(this).appendTo('#s_prod'); }); }); $('#revert').click(function () { debugger $('#s_prod option').each(function () { currentOptIndex = $(this).data('prevIndex'); if(currentOptIndex > 0) $('#p_prod option').eq(currentOptIndex).after(this); else $('#p_p

Categories : Jquery

how to set value of column to a string out of selected options?
you can get a random number in range 0 to 3 using select aBS(CHECKSUM(NewId())) % 4 This works because newid() is a non deterministic function, and will return a different (random) value for each row. So use this to seed a case statement update table set type = case aBS(CHECKSUM(NewId())) % 4 when 0 then 'Tv' when 1 then 'Radio' when 2 then 'Magazine' when 3 then 'Internet' end

Categories : SQL

Preload selected options for select
Here is 'a' way. Define a template: <script type="text/template" id="category_options_template"> <select id="CategoryId" name="CategoryId"> <% _(categories).each(function(c) { %> <% if (c.get('IsSelected') == "selected") { %> <option value="<%= c.get('CategoryId') %>" selected="selected"><%- c.get('CategoryName') %></option> <% } %> <% if (c.get('IsSelected') == "") { %> <option value="<%- c.get('CategoryId') %>" id="<%- c.get('CategoryName') %>"><%- c.get('CategoryName') %></option> <% } %> <% }); %> </select> </script> Fetch your items that are supposed to end up in the drop dow

Categories : Ruby On Rails

Show/hide div for selected options
Keeping hidden divs for all possible combinations is not a good idea. That will make your page size bigger. Why don't you get only the relevant information as needed using ajax and show it ? In your page, keep only one div to show the information <select id="Age"> <option value='1'>18-24</option> <option value='2'>25-50</option> </select> <select id="Place"> <option value='1'>Asia</option> <option value='2'>America</option> </select> <div id="info"></div> Now listen to the change event of the dropdowns, get the selected value of dropdowns and make an an ajax call to the server page and get the markup to show to user. In the below script, I am using jquery load method to load the new

Categories : Javascript

sum values of selected options with initial value
You can use a html5 attribute: <label id="starting_price" data-startprice="45.00">45.00</label> You can access this with one of these: $('#starting_price')[0].dataset.startprice (this is native JS, my preferred) or $('#starting_price').attr('data-startprice') or $('#starting_price').data('startprice') Because this doesnt change, you can always get back to it $('select').change(function(){ var sum = Number( $('#starting_price')[0].dataset.startprice );// get the data-attribute $('select :selected').each(function() { sum += Number( $(this).val()); }); $("#starting_price").html(sum); }); Here you can find some documentation on data attribute with javascript

Categories : Javascript

How to get the text of the selected option(s) in angular using ng-options
Here's an example that transforms the array to a String and displays it as a string directly in the page: JS: $scope.selectedDaysToString = function() { return $scope.day.join(', '); } HTML: {{selectedDaysToString()}} And here is an example that generates a list containing all the selected days: HTML: <ul> <li ng-repeat="d in day">{{d}}</li> </ul>

Categories : Angularjs

Spring and JSP: post all options in multiselect, not only selected ones
You should write a JS code on "onsubmit" event of form to programatically select all the options of multiselect. (Thus, making all options blue) Like in jQuery, $('#form #selectId option').attr('selected', 'selected'); I don't see better way of doing it.

Categories : HTML

Get data attribute for selected dropdown options
Try this, HTML Add id attribute to your select drop down like <select id="sampleorder" > .... SCRIPT var sampleAmount = $('select#sampleorder option:selected').data("amount"); Fiddle http://fiddle.jshell.net/3gCKH/

Categories : Javascript

Change what is displayed based on selected options
Okay, so I attempted to understand your question better. You have 2 drop down lists and when they are updated to equal scores you want then the values show. I have created a fiddle for this here: http://jsfiddle.net/Vsd3G/5/ HTML is largely unchanged - removed the duplicate ids, etc: <div id="segmentscore"></div> <div id="segmentaware"></div> <div id="select1"> <select id="genderlist"> ... </select> </div> <div id="select2"> <select id="agelist"> ... </select> </div> I create an array of "scores" which specify your genderage select index + scores and "aware" there. var scores = [{ gender: 1, ages: 1, score: 100, aware: 150 }, { gender: 1, ages: 2, score: 190,

Categories : Jquery

Jquery to update price when one or more options selected
To calculate the total price, get the value of both and add them to the base price whenever the value is changed on one of the selects. You can display this in the item-price span using the html() function. Working Demo HTML Colour: <select class="vars" name="size"> <!-- set defaults to price=0 to save you from having to do validation --> <option data-price="0">Select an option</option> <option data-price="-10.00" value="B">blue -10</option> <option data-price="20.00" value="G">green +20</option> <option data-price="30.00" value="Y">yello +30</option> </select> <br> Size: <select class="vars" name="size"> <option data-price="0">Select an option</option

Categories : Jquery

How to get Selected option value from html:options collections
Change your tag to <html:select property="temp_Id" styleId = "tempId" > html:options collection="listmap" property="key"/> </html:select> Add the following in your java script var e = document.getElementById("tempId"); var strUser = e.options[e.selectedIndex].value; This should do.Thanks.

Categories : Java

access current selected element with in the options
The this you have is probably the global object or if you're in an event handler the object for which the handler was bound. Anyway to get the proper context you can use the each function to set the url according to the specific li. $("#pollList li").each(function(){ $(this).popup({ width:800, height:400, popupType:'ajax', ajaxURL:root+'polls/attend/poll/'+$(this).attr('pollId') }); }); Also you might want to use data attributes rather than arbitrary one.

Categories : Jquery

display selected checkbox options on the page
HTML <form id="extras"> <label id="lbl_1">option 1</label><input type="checkbox" name="box" value="2000" id="1" onchange="calculate()"><br> <label id="lbl_2">option 2</label><input id="2" type="checkbox" name="box" value="500" onchange="calculate()"><br> <label id="lbl_3">option 3</label><input type="checkbox" name="box" value="150" id="3" onchange="calculate()"><br><br> </form> <span id="txt"></span> Calculate function function calculate() { document.getElementById("txt").innerHTML = ""; var checkBoxes = document.getElementsByName("box"); for(var i=0; i < checkBoxes.length;i++) { if(checkBoxes[i].checked)

Categories : Javascript

selected options for multi select Jquery in PHP
You need to give your <select> element a name attribute. <select name="myselect[]" multiple="multiple" size="5"> Then when the form is submitted to a PHP file, the selected options will be in either $_GET['myselect'] or $_POST['myselect'] depending on the form's method attribute.

Categories : PHP

I want to save Multiple checkbox selected options into MySQL
Simply implode the $_POST['type'] array like so.... $types = implode(",", $_POST['type']); Then insert that $types variable into your table... So... $types = implode(",", $_POST['type']); if($types){ $order = "INSERT INTO tblsampo (patno, stno, type) VALUES ('$smonth', '$patno','$stno','$types')";}

Categories : PHP

jquery selected options multi select works once
Try .prop('selected', false) instead (http://api.jquery.com/prop/), it works fine I think $(document).ready(function() { $("a#click").click(function(){ $('#maleLicense').children(':selected').prop('selected', false); $('#femaleLicense').children(':selected').prop('selected', false); }); }); Updated jsfiddle: http://jsfiddle.net/7x9BT/3/

Categories : Jquery

Getting configurable product options pre selected from the layered navigation
There is no ready-made way to do this. When the request is made for the product that product knows nothing of the layered navigation state. In theory you could add in some server side code to do that however this might have a performance penalty as you might not be able to use cache effectively. You could do something on the front end in javascript. Add an event listener to the links in the filtered navigation and store an object in local storage, e.g. with size and colour. On the product page you could then set the configurable product according to those values by waiting for the configurable product options to be built, then load the options object from local storage and then update the configurable product accordingly. You will need to then fire off events so the product page knows th

Categories : Magento

Replacing [+] View list of options I selected using Jquery
yes try something to the effect of $("a").click(function(){ $(this).html(this.id); }); it's simplest if you just add id's, otherwise you would replace the this.id, with something a lot more complicating.

Categories : Jquery

Angularjs: ng-options
It is model driven, you need to set $scope.clientList to the client id. In your controller you can do something like this function Ctrl($scope) { $scope.clients = [{ id: 1, clientName: 'Joe' }, { id: 2, clientName: 'Tom' }, { id: 3, clientName: 'Bob' }]; $scope.clientList = 2; //clientList is the model defined in the select directive } Demo on jsFiddle And if the id field is a string, you should set clientList as string rather than integer: $scope.clientList = "245";

Categories : Angularjs

jQuery loop giving all
It's giving you the text from the td that contains the select, because you've specified .projects_editable_content_td. You need to exclude the .projects_editable_content_td that contain a select. See the code I posted to your question from yesterday.

Categories : Javascript

PHP Save selected options from Multiple Drop Downs to an Array
Do you mean <?php var_dump($_POST); ?> <form method='post'> <select id='rq1' class='business' name='q1[]'> <option value='1'>1</option> <option value='2'>2</option> </select> <select id='rq2' class='business' name='q1[]'> <option value='1'>1</option> <option value='2'>2</option> </select> <select id='rq3' class='business' name='q1[]'> <option value='1'>1</option> <option value='2'>2</option> </select> <input type='submit'> </form> When you submit the form, you will get data in Array.

Categories : PHP



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