w3hello.com logo
Home PHP C# C++ Android Java Javascript Python IOS SQL HTML Categories
HTML
Select has no value attribute in HTML - you can have multiple options selected, and this is determined by the selected attribute on the option element Mucky way: <select name="status"> <option<?php if ($row['status'] == "In Inventory"): ?> selected="selected"<?php endif; ?>>In Inventory</option> <option<?php if ($row['status'] == "In Process"): ?> selected="selected"<?php endif; ?>>In Process</option> <option<?php if ($row['status'] == "Shipped/in-transit"): ?> selected="selected"<?php endif; ?>>Shipped/in-transit</option> <option<?php if ($row['status'] == "Received by recipient"): ?> selected="selected"<?php endif; ?>>Received by recipient</option> </select> Sli

Categories : PHP

jQuery - on page load select optgoup and children in second select by a default selected option in a parent select
Have you put your code in a $(document).ready() function? Assuming your code does what you want when the user selects a different country, this is what you want to change your code to: // sets the option group using the same code you already use for on-country-change function setOptGroup() { var state_province = $('#userstate option, #userstate optgroup'); state_province.hide(); // EDIT: this line won't retrieve selected country when page has just been loaded //$("#userstate optgroup[label='" + $(this).find(':selected').html() + "']") // this line works $("#userstate optgroup[label='" + $('#usercountry').val() + "']") .children() .andSelf() .show(); } $( document ).ready(function() { // set up the USA option group when the page is load

Categories : Javascript

Update default select option when filtering select list
I think this is what you need: Fiddle Basically, when the user changes the type by switching between the radio buttons, the watch will be triggered that will reset the selected option. Thus, when changing the types, it ensures that the model associated with the selected option is reset. $scope.$watch('selectedType', function (newValue, oldValue) { if (newValue !== oldValue) { $scope.selectedOption = null; } });

Categories : Javascript

how to use ng-option to set default value of select element
So assuming that object is in your scope: <div ng-controller="MyCtrl"> <select ng-model="prop.value" ng-options="v for v in prop.values"> </select> </div>   function MyCtrl($scope) { $scope.prop = { "type": "select", "name": "Service", "value": "Service 3", "values": [ "Service 1", "Service 2", "Service 3", "Service 4"] }; } Working Plunkr: http://plnkr.co/edit/wTRXZYEPrZJRizEltQ2g

Categories : Angularjs

How to have a default option in select box - Angular.js
Try this: HTML <select ng-model="selectedOption" ng-options="option.name for option in options"> </select> Javascript function Ctrl($scope) { $scope.options = [ { name: 'Something Cool', value: 'something-cool-value' }, { name: 'Something Else', value: 'something-else-value' } ]; $scope.selectedOption = $scope.options[0]; } Plunker here. If you really want to set the value that will be bound to the model, then change the ng-options attribute to ng-options="option.value as option.name for option in options" and the Javascript to ... $scope.selectedOption = $scope.options[0].value; Another Plunker here considering the above.

Categories : Javascript

how to create a select without an option by default
This works: http://jsfiddle.net/bW7k7/1/ $("#addLang").on("click", function(){ var lang =$("#updLanguage :selected").text(); var idLang =$("#updLanguage").val(); if($("#langList").is("div")) { $("#langList").replaceWith($('<select id="langList">' + this.innerHTML + '</select>')); } $("#langList").append("<option id='"+idLang+"'>"+lang+"</option>"); });

Categories : Javascript

Set select menu default option
You initialize the variable to 1. (You initialized it to 3 in your code) http://plnkr.co/edit/rld39zJIHwIg0mOe7p1u?p=preview Could you be more specific about what you want to do in the 2nd part of your question?

Categories : Angularjs

jquery select box selection default option
$(".t_type option:first").attr('selected','selected'); or $(".t_type").prop('selectedIndex',true); reference attr and prop

Categories : Jquery

How do I add a blank default option to a select widget?
After playing around with it for a while, I discovered what I needed to do: FIELD_ONE_CHOICES = (('', '-----'),) for datum in my_model.objects.distinct('field_one'): FIELD_ONE_CHOICES += ((datum.field_one, datum.field_one),) FIELD_TWO_CHOICES = (('', '-----'),) for datum in my_model.objects.distinct('field_two'): FIELD_TWO_CHOICES += ((datum.field_two, datum.field_two),) search_form = modelform_factory(my_model, fields=('field_one', 'field_two'), widgets={'field_one': Select(choices=FIELD_ONE_CHOICES), 'field_two': Select(choices=FIELD_TWO_CHOICES), } ) Tuples can be frustrating...

Categories : Django

KnockoutJs Setting Selected Option in a Select tag is not working
There is nothing wrong with your options binding but how you've set the initial values in SelectedOption and SelectedOption2. Because Options is a ko.observableArray you need to get its underlaying array with calling it as function with self.Options(). So you've missed the () in your code, the correct version should look like this: self.SelectedOption = ko.observable(self.Options()[2]); self.SelectedOption2 = ko.observableArray([self.Options()[2]]); Demo JSFiddle.

Categories : Knockout Js

how can i make a default value if the option value of a select tag isnt a specific value?
I haven't tested it, but this should work <select name="corequisite"> <?php // this is your string that will return all your results $to_echo = ''; // this will check if any value inside is selected ( this will be useful later ) $any_item_selected = false; $res = mysql_query("SELECT * FROM course"); while($row = mysql_fetch_array($res)) { if($row['Code']==$result['corequisite']) // OK! so one item is selected, remember it! { $to_echo .= '<option selected="selected" value="'.$row['Code'].'">'.$row['Name'].'</option>'; $any_item_selected = true; } else $to_echo .= '<option value="'.$row['Code'].'">'.$row['Name'].'</option>'; } // Now we can check if any

Categories : PHP

Select option default based on database variable
That should do it: <select > <option value="1" <?php echo ($Defaultselection == 1)?"selected":""; ?>>A</option> <option value="2" <?php echo ($Defaultselection == 2)?"selected":""; ?>>B</option> <option value="3" <?php echo ($Defaultselection == 3)?"selected":""; ?>>C</option> <option value="4" <?php echo ($Defaultselection == 4)?"selected":""; ?>>D</option> </select> or this other one: <select > <option value="1" <?php if ($Defaultselection == 1) echo "selected"; ?>>A</option> <option value="2" <?php if ($Defaultselection == 2) echo "selected"; ?>>B</option> <option value="3" <?php if ($Defaultselection == 3) echo "selected";

Categories : HTML

Prevent select option from changing back to default
You will need to store the state of the dropdown either using server or client side technology. In client side you can use a cookie or html5 storage like local storage to store the selected value and when the page is revisited and there is a stored value then you can select that value instead of the default value If you are planning to use cookie to store the information, then you can think of a jQuery plugin like this or this An abstract implementation might look like $('select').change(function(){ storeValue('mykey', $(this).val()); }) function storeValue(key, value){ $.cookie(key, value) } function getValue(key){ return $.cookie(key); } $(function(){ var val = getValue('mykey') || 'Full Name'; $('select option[value="' + val + '"]').prop("selected",true); });

Categories : Javascript

dynamically setting selected option in ember.select which uses select2 lib
I wrote a select2 view that extends Ember.Select. You can find the gist here. You can use in it place of Ember.Select. I am not sure what is going wrong with your example, but you are having the controller manipulate the view, which is not good form. Have the view observe the controller content and update upon change.

Categories : Ember Js

Setting the default value to a select list
I think you'd have to do this: public static readonly List<string> LIST_ITEM_STATE = new List<string> { string.Empty, "Brand new", "Never used", "Slightly used", "Used", "Heavily used", "Damaged", "Ruined", "Run for your life" }; And set the selected value in the SelectList: mItemStateList = new SelectList(ValueDomain.LIST_ITEM_STATE, "Brand new"); Or make sure the value of the the property is set to the initial value you want: _item.mItemState = "Brand new";

Categories : C#

How select default option of dynamically added dropdown list
You are not providing the right id. Your select's id is mysel and you are trying to select an option in mydiv. Change $("#mydiv").val("3"); to $("#mysel").val("3");

Categories : Javascript

Load select option from JSON data according to previous select data
This line is what's wrong in your JS : $.each(data[$(this).val() - 1], function() { $this.val(), in this context, means the value of inputGender, which can be "m" or "w". You must have pasted this code from somewhere else, because it assumes integer values. Try changing your data to this : var data = { m: [{"ID":"1","desc":"(12)"},{"ID":"2","desc":"(5)"},{"ID":"6","desc":"(15)"}], w: [{"ID":"0","desc":"(49)"},{"ID":"7","desc":"(5)"}] }; and then you can use $(this).val() to get the array you want : $("#inputGender").change(function() { var $persons = $("#inputWeight").empty(); $.each(data[$(this).val()], function() { $persons.append("<option value=" + this.ID + ">" + this.desc + "</option>"); }); }); See it working live in this fiddle.

Categories : Javascript

Setting default value in select drop-down using Angularjs
When you use ng-options to populate a select list, it uses the entire object as the selected value, not just the single value you see in the select list. So in your case, you'd need to set $scope.object.setDefault = { id:600, name:"def" }; or $scope.object.setDefault = $scope.selectItems[1]; I also recommend just outputting the value of $scope.object.setDefault in your template to see what I'm talking about getting selected. <pre>{{object.setDefault}}</pre>

Categories : Angularjs

Setting Ember.Select Default Selected Value
The selectionBinding is the right parameter to set on a Ember.Select but it should be an item contained in the array you pass to its contentBinding, so doing it like the following should work. Define a property on your App.OptionController to hold the selected item: App.OptionController = Em.Controller.extend({ selectedOption: Ember.computed.alias('content.firstObject'), init: function() { this._super(); this.set('model', this.get('store').find('option')) } }); And set this property as your selectionBinding: {{view Em.Select prompt="test" contentBinding="controllers.option.content" optionLabelPath="content.name" optionValuePath="content.id" selectionBinding="controllers.option.selectedOption" }} Working demo. Hope it helps.

Categories : Javascript

kendo dropDownList issue where setting index not working to select initial option value
The problem is not in your kendoDropDownList but the fact that you set the color multiple times. You set it in Kendo DropDownList when you say: $("#color").kendoDropDownList({ dataTextField: "text", dataValueField: "value", dataSource: data, index: 2, change: onChange }); You do it again in: color.select(0); And once again in: <input id="color" value="1" /> Try removing all but one and you get the right value. Check it here http://jsfiddle.net/OnaBai/E57J3/8/

Categories : Kendo Ui

A custom array-type object that pulls data from different sources
You are pretty much there based on what you are asking for just a couple modifications: class MyClass include Enumerable def initialize(base_data) @base_elements = base_data # this is an array @extra_elements = [] # this stores the "new" data end def add(elem) @extra_elements << elem end def delete(elem) @extra_elements.delete(elem) end def all_elements @base_elements.concat(@extra_elements) end def index (elem) all_elements.index( ... ) end def each(&block) all_elements.each(&block) end end

Categories : Ruby

Firefox select dropdown keeps refreshing/reverting to default option due to running Javascript - AngularJS
It seems like the creating the 'option' elements through ng-options is the root cause to this issue. I've altered the code a bit to make sure if that's the problem See the plunkr http://plnkr.co/edit/DLf2wvVGXRiwci6FhqQO?p=preview What I've done is to move the creation logic of the options to ng-repeat. That'll fix the issue for now.

Categories : Javascript

Setting a default value when creating a new object of a model
You're pretty close. Since you've 1) been provided the current_user convenience helper by Devise, and 2) configured User and Post as a has_many/belongs_to relationship, it makes sense to create the new post, then append it to current_user. Then, in your Post model, you'll want to break up validations for individual attributes – the way you've listed :content, :title in sequence won't work. # app/controllers/posts_controller.rb def create post = Post.create(params[:post]) current_user.posts << post end # app/models/post.rb class Post < ActiveRecord::Base attr_accessible :content, :title, :user_id validates :content, :presence => true validates :title, :presence => true belongs_to :user end

Categories : Ruby On Rails

Get value from the user selected option on select option element and update the input form based on chosen option
You'll need to get the value of the selected option inside your handler, otherwise the variable won't be updated with the current value. Also, jQuery selectors are case sensitive, so you'll need to use #Reason not #reason. This should work for you: $('#Reason').on('change', function(){ var selectedOption = $(this).find("option:selected").text(); alert(selectedOption); }); Working Demo

Categories : Jquery

Setting default value in Oracle Object Type Constructor Function
In your second code block, you aren't calling the constructor that only has two arguments. Passing a null argument doesn't mean you use the other constructor, you're calling the (default) constructor with four arguments, two of which just happen to be intentionally null. You're effectively doing: TYPE_MAIN(col1 => '1', col2 => NULL, col3 => NULL, col4 => NULL) not TYPE_MAIN(col3 => '1', col4 => NULL) So this works: INSERT INTO TAB_MAIN(PKEY,COLTEST,COLNEW) VALUES(1,'TESTCOL2',TYPE_MAIN('3','4')) / ... PKEY COLTEST COLNEW ---------- --------------- -------------------------------------------------- 1 1 TESTCOL TYPE_

Categories : Oracle

Java: Null Pointer exception while setting a Text.Attribute Object to it's default value, why?
Replace your Hashtable with HashMap. Hashtable do not allow null value.So you are getting NullPointerException. According to java docs put() Throws: NullPointerException - if the key or value is null. Please have look into these SO Questions. 1.Why Hashtable does not allows null keys or values? 2.Differences between HashMap and Hashtable?

Categories : Java

ng-option dropdown list of objects not setting ng-option when selected = true
The data structure doesn't make sense, you need a list of objects (JSON) like this $scope.subjects = [{ id: 1, name: 'english' }, { id: 2, name: 'maths' }, { id: 3, name: 'computers' }]

Categories : Angularjs

how to set the default 'select' ng-model to an object?
ng-options is generating some options to be used with ng-model. In your syntax (prop.name for prop in params.properties) you've told it to bind to the object found in the array (as oppose to a property on it - which is what you want to do) and use its name property as the value to display. So when you try and set the ng-model to be an object that's not in the ng-options array nothing happens - I'm guessing because it's using reference/shallow equality and not deep equality. So what you should do is either: Convert the ng-options object to be an array of strings. Use a syntax that involves keys, such as: prop.name as prop.name for prop in params.properties http://jsfiddle.net/C5ENK/ If that doesn't suit your needs let me know why and I'll see if I can help further.

Categories : Angularjs

how to retrieve data from select option in php with GET
Your PHP code is generating the following code : <option> <OPTION value="your id #1"> Username </option> Can you try with : <select name="users"> <?php $sql = "SELECT * FROM users"; $result = mysql_query($sql) or die (mysql_error()); while ($row = mysql_fetch_array($result)) { $id=$row["id"]; $username=$row["username"]; $options.="<OPTION VALUE="$id">".$username."</OPTION>"; } ?> <? echo $options ?> </select>

Categories : PHP

How do I disable select option fields when I select a previous option?
Looks like you need something like that: $("#amp").on('change', function () { $("#cab").prop('disabled', $(this).val() == "Amplifier 2") }); http://jsfiddle.net/gvalmon/shgfk/ More details in question may help to find better solution.

Categories : Jquery

jQuery trying to get value of one select option based on result of another select option
Try this: $(document).ready(function () { $('#selOption').change(function () { $('#txtID').val($(this).val()); $('#txtOption').val($('#selOption option:selected').text()); $('#selItem').val($(this).val()); $('#txtItem').val($('#selItem option:selected').text()); }); $('#selItem').change(function () { $('#txtID').val($(this).val()); $('#txtItem').val($('#selItem option:selected').text()); $('#selOption').val($(this).val()); $('#txtOption').val($('#selOption option:selected').text()); }); }) Demo here

Categories : Javascript

Create a data-persistent select option
From the information that you provided I think the problem is with the character in the ColdFusion code. You need that to escape the quotation marks for the JavaScript code but not for the ColdFusion code. Try removing those characters from the <cfif> statements in the JavaScript code. Instead of this: <cfif form.highschoolcity EQ "abbeville">selected="selected"</cfif> Try this: <cfif form.highschoolcity EQ "abbeville">selected="selected"</cfif> You do not need to escape the quotation marks in the ColdFusion code because the ColdFusion server will process that code before it is output to the user's browser.

Categories : HTML

Binding data to a combobox and add a select option
You could try adding a custom objSize object to the objSizes collection that has ID = 0 and value = "Select size..." as it's ID 0 it should be at the top (I think) and won't clash with any values in your database, upon saving the record you can validate the combobox to avoid writing the "Select size..." object to your database. I'll have a bit of a code and see if this will work... Ok, I've had another look. You can do as I suggested but you must sort the list before passing it to the combobox. Here is my example: Public Class Form1 Private Sub Form1_Load(sender As Object, e As EventArgs) Handles Me.Load With Me.ComboBox1 .DisplayMember = "Description" .ValueMember = "ID" .DataSource = GetListOfObjects.returnListOFObjects End With

Categories : Vb.Net

media element setting up multiple sources with jquery
Per the source, setSrc() can take either a single string, or an array of URL/type objects. e.g. mediaElement.setSrc( [ { src: 'audio/budget_2.ogg', 'type': 'audio/ogg' }, { src: 'audio/budget_2.mp3', 'type': 'audio/mpeg' } ] );

Categories : Jquery

Rails form_for setting options and setting selected option
The parameters of f.select are: attribute_name,option_tags,options. option_tags is supposed to be a string of html option tags. There are some helpers to construct such a string from i.e. an array of values, a collection etc.: options_for_select, options_from_selection_for_select. You have to use one of these helpers. You can get the existing vehicle_sizees with: Model.pluck(:vehicle_size).uniq so your select could look like: <%= f.select :vehicle_size, options_for_select(Model.pluck(:vehicle_size).uniq,@model.vehicle_size) %> See the Rails Guide on form helpers.

Categories : Mysql

How to fetch data that will be stored in the select option value in the form?
That's quite easy to do as you understand what steps you need to take. Send an AJAX request on some JavaScript event you desire. In your case it is onchange of the first <select>. You can of course send XMLHttpRequest on your own, but that's much easier (and stable) to do by using a well-established JS library like jQuery. The request is received by a dedicated servlet that accepts some data that will be used to fetch the necessary data in java code and send the fetched data in JSON format back to the webbrowser. The incoming data is the value of the selected <option> of the first <select> element and possibly, id of the fetch operation, if you intend to use this servlet for other purposes. Serialization of data returned from the servlet to JSON format can be done by us

Categories : Java

Append select option with an HTML5 data attribute using jQuery
Actually the data is set, but since you are using data method instead of the attr method, it's not visible. jQuery stores the value behind the scenes, for getting the value you can use .data('sym'). If you want to set the value as an attribute you can use attr method instead.

Categories : Jquery

Shiny: Select option automatically takes data variables
If you see ls() in code, it's almost always wrong. The tricky part, however, is setting an ui item from server: you need the update---- family of functions for that. Here is the part that fills the names of the csv into the product table. You have to add some more standard code to do the filling. #server.r library(shiny) shinyServer(function(input,output,session){ observe({ inFile<-input$file1 print(inFile) if(is.null(inFile)) return(NULL) dt = read.csv(inFile$datapath, header=input$header, sep=input$sep) ## Decide later what to do with the data, here we just fill updateSelectInput(session, "product", choices = names(dt)) }) }) #ui.r library(shiny) shinyUI(pageWithSidebar( headerPanel( "Demand Forecast", "Flowserve"), sidebarPanel( fileInput

Categories : R

Tell Chrome which include files I want opened by default in devtools' Sources tab
Right now, DevTools will remember what tabs you last had open, but you can't really configure beyond that. The good thing is cmd+o is really fast for opening up files, and it'll soon be getting some improvements in its scoring so most relevant files will be at the top.

Categories : Google Chrome

Linux/Unix - Setting default file/folder permissions using ACL, executable permission not setting?
It's not setting the execute bit because files are only created with execute permission if the application explicitly requests it. Since it makes no sense to make an .html file executable, whatever program created it did not request execute permission to be added, so it has no execute permission. Consequently, execute permission from the default ACL effectively only applies to directories, not to files. As for why the default group is not set to ftp, this is more subtle. The default ACL is just that -- an ACL. It's not a default group ownership. As such it shows up not in ls but in getfacl: # mkdir public # setfacl -R -m u::rwx,g:ftp:rwx,d:g:ftp:rwx,o::rx public/ # getfacl public # file: public # owner: root # group: root user::rwx group::r-x group:ftp:rwx mask::rwx other::r-x defa

Categories : Linux



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