FAQ Database Discussion Community


Rails options_for_select return value only

ruby-on-rails,forms,options,view-helpers
I working on a project in Rails and trying to figure out how to return just the value, using options_for_select. For example. options_for_select([["Dollar", "$"], ["Kroner", "DKK"]]) # => <option value="$">Dollar</option> # => <option value="DKK">Kroner</option> I only want to return $ or DKK (i.e the value) instead of the full <option...

Disable selected options based on the user's decision

jquery,html,select,options
I'm trying to create an open environment for the user to choose a particular option, yet at the same time give them the open opportunity to choose them in any order, yet eliminating the choices they've chosen. My code so far stops me in my tracks when executing them out...

Python handling options and args

python,arguments,command-line-arguments,options,getopt
I have written a python code and I want to handle switches and arguments. So I want to tell script: If you see -u then there is no -d <name> in arguments print "sth": if sys.argv=='-u' and sys.argv!='-d': print "You must use the -d switch!" sys.exit() Seems this is wrong...

How to make jqGrid dynamically populate options list based on row data

dynamic,jqgrid,options
I am using jQrid version 3.8.1 with inline editing and each row in the grid has several dropdown lists to populate. When the user edits the row, I need to do an AJAX query to get the values for each of these lists. I've seen this post regarding how to...

Create options onClick attribute

javascript,select,onclick,options
This is the idea: When I click on "word1" (or "word2") the select tag shows me the options. Once I click on one of the options, my script change "word1" (or "word2") whit the option. I can update the options, but once I click on one of them the script...

Chrome extension options

javascript,google-chrome,google-chrome-extension,options
In the manifest.json of my extension, I added this: "options_ui": { "page": "options.html", "chrome_style": true }, My options page (options.html) has this right before the closing body tag: <script src="options.js"></script> Both options.html and options.js are in the same folder. options.js starts with this: console.log('options.js'); Problem: I am loading the unpacked...

What is the use of different OnBeforeRequestOptions and OnHeadersReceivedOptions?

google-chrome-extension,options,webrequest
From the WebRequest API, I see there are multiple options available as onBeforeRequestOptions Enum "blocking", or "requestBody" OnBeforeSendHeadersOptions Enum "requestHeaders", or "blocking" I understand We need to pass "blocking" when we need to modify the Request in blocking fashion. My question is When do we need the other options ?...

Apache Commons CLI(Options)

java,command-line-interface,options
I have been learning how to use Apache commons CLI. I want to use the options class to describe the possible options for a command-line, but I have seen in some tutorials that they use two ways to add a new option. The first is this: options.addOption( OptionBuilder.withLongOpt( "block-size" )...

Angular ng-options for bounded select elements

angularjs,select,options,ng-options
I'm almost there but stuck on one little detail. I can't seem to get the "name" property of the selected Car Make's "Car Model" to actually show up on the select menu. At the moment, it seems to be showing the correct number of options, but the options are visibly...

How to use variables in option parameters for a plugin (like fullpage.js)?

jquery,variables,plugins,options,fullpage.js
I've been looking for hours to find the answer of my problem, but could'nt find anything usefull. I'm using the fullpage.js plugin, one of the various option is "anchors". I'd like to use this one but I'll never know the link's names that I've to put in it. They can...

How do I define values in options_for_select?

ruby-on-rails,select,erb,options
I have this options_for_select call: <%= f.select(:agents, options_for_select(@agents), {},{multiple: true, size: 10, :id => "agents"}) %> There are only currently 2 agents in the database but they are showing up as #<Agent:0x007fc1b121c490> format. I want them to display as @agent.name and for the value to be @agent.id. How do I...

Jquery, using $.each, doesn't get the value of variable

jquery,select,add,each,options
I'm using Jquery to add some options to a select, but, the options are not always the same, so, I use a variable called materia to get the value of a previus select to know which options I should add. I dont know if Im explaining correctly, here's some code....

display number of elements depending on option selected

javascript,jquery,select,options
I'm trying to add a 3rd filter to track/display the number of elements shown depending on the option selected (#filter9). This is what I have so far, I got the code from: Filter based on combination of multiple select and single select elements. This is what i'm trying to edit:...

Visual Studio 2013 code snippets / code templates

visual-studio,preferences,options
I.e. in eclipse there is a place where I can define my own user keywords for autocomplete like: word: else And template to paste: else { ${cursor} } Sorry if this is naive but so far I'm unable to discover such feature in Visual Studio. Does any one of You...

PayPal button overflow

button,paypal,responsive-design,overflow,options
I'm using Squarespace and all elements are responsive, except for the code block. So, when I add PayPal buttons, an overflow appears... Like this: http://static1.squarespace.com/static/537a5c42e4b0f3418c1f0939/t/54f398c0e4b02ef942b49034/1425250496634/Untitled-2.jpg I managed to correct this problem for the button image using the width:100% atribute, but it doesn't seem to work with the options. I also...

Accessing option data

python,command-line-arguments,options
I am trying to add an option to a Python program like so: optionParse= argparse.ArgumentParser(description='Change Number of Locations') optionParse.add_argument('-n') The -n option will allow the user to specify a number that will be used in the program. They will input it like this: myProgram.py -n 12 How would I access...

Scala - Map with default value None?

scala,dictionary,return-value,options
Given trait A case class B extends A trait C I'm trying to implement something akin to this: val m = scala.collection.mutable.HashMap[String, C=>Option[A]]( ... //some pre-defined mappings ).withDefaultValue((_:C) => None) This will give me a type mismatch: expected: C=>Option[A], actual: C=>None.type I heard scala expects None to be returned from...

Correct extend user option in jQuery plugin [closed]

javascript,jquery,plugins,jquery-plugins,options
There is example of jQuery plugin in which user can set own options (function( $ ){ var options = { opt1: val1, opt2: val2, opt3: val3 }; var methods = { init : function( options ) { var option = $.extend({ opt1: val11 }, options); }, show : function( )...

Selecting and removing a html select option without selecting by index or ID, using vanilla JavaScript

javascript,function,select,options
I need to remove an option on a select box, and I've figured out a potential solution in the code below, but it doesn't feel particularly 'safe' (if another developer decided to add an option to the backend, the option will re-appear). Is there a better way of achieving this...

jQuery Getting Values of Selected Selectboxes (Display in real-time)

jquery,html,forms,select,options
I'm working on a jQuery input to get all the values of the selectboxes clicked on select options. When I click all the values after the first option, I am unable to see the selected values unless I go back and re-click the first option. What I'm trying to do...

Crm 2011/2015 set select to null

dynamics-crm-2011,updates,options
I have on a page an option set that has been valorized with a value. I would like to update this value and set it to null. I am trying in this way Crm.Context.Account myAccount = new Crm.Context.Account(); myAccount.Id = "1af43..."; myAccount.Name = "bla bla bla"; myAccount.psw1_TipoSoc= null; OrganizationRequest request...

A hierarchical options assignment inheritance

java,inheritance,options
I am designing an option assignment framework. I've constructed an option class: public class MyOptionModule { public MyOptionModule() { } public void addOption(String option, String explanation) { //... } public void printHelp() { //... } public void parse(String[] args) { //... } } For every module which requires users to...

Zsh redirection 2>>|

zsh,options,io-redirection
I came upon this which I am replicating in order to debug a zsh line editor widget, and I realized that I have no actual idea what 2>>| actually does. Presumably feed stderr into a file, but what's the deal with the |?

CSS : Setting font-family in select options doesn't work for chrome and IE browsers?

css,options,fontfamily
I want to define different font-family styles to options of a select, for example : <select> <option style="font-family:Arial;">AAAA</option> <option style="font-family:Times New Roman;">AAAA</option> <option style="font-family:Comic Sans MS;">AAAA</option> </select> But this code doesn't work in IE and Chrome Browsers. An idea ? Thank you in advance, cordially....

Scala Illegal Start of Simple Expression: Option Type and Ellipsis

scala,pattern-matching,option,options,ellipsis
New to Scala and just began the scala.Option Cheat Sheet. However, this code is throwing an error in the sbt console. def option[A, X](o: Option[A])(none: => X, some: => A => X): X = ... The error is error: illegal start of simple expression the up-arrow points to the ellipsis....

change the content of a select option

jquery,forms,select,text,options
I'd like to change the text shown in a select form, without changing the HTML elements. This is an example: <select class="myclass" name="myselect"> <option value="0">1</option> <option value="1">2</option> </select> I would like to change the "2" string into "TWO", for example, like: <option value="1">TWO</option> I'm not able to select the right...

How to stop intelisense from auto-completing UNLESS i press space or a specific character to activate it

c#,visual-studio-2012,intellisense,options
I'm trying to write some code in C# in visual studio after a while working mostly on c++ and the settings for C# are driving me nuts. I hate hate hate auto complete activating at the touch of any number of characters I might type as part of a single...

Ruby 2.1.3 options hash cannot be assigned with fetch

ruby,hash,fetch,options
Please explain to me why this is happening: def resizeImage(event_file, resize_width, resize_height, options = {}) puts options aspect_ratio = options.fetch(:maintain_aspect_ratio, true) puts aspect_ratio "return value" end resizeImage('event_file', 'resize_width', 'resize_height', {maintain_aspect_ratio: false} ) {:maintain_aspect_ratio=>false} false => "return value" I want to set a variable to = the fetch from the hash...