default-value

Javascript Get Element by Id and set the value

前提是你 提交于 2019-11-27 10:04:42
问题 I have a javascript function to which I pass a parameter. The parameter represents the id of an element (a hidden field) in my web page. I want to change the value of this element. function myFunc(variable){ var s= document.getElementById(variable); s.value = 'New value' } When I do this, I get an error that the value cannot be set because the object is null. But I know the object is not null because I see it in the html code generated by the browser. Anyways, I tried the following code to

SQL Column definition : default value and not null redundant?

两盒软妹~` 提交于 2019-11-27 09:49:12
问题 I've seen many times the following syntax which defines a column in a create/alter DDL statement: ALTER TABLE tbl ADD COLUMN col VARCHAR(20) NOT NULL DEFAULT "MyDefault" The question is: since a default value is specified, is it necessary to also specify that the column should not accept NULLs ? In other words, doesn't DEFAULT render NOT NULL redundant ? 回答1: DEFAULT is the value that will be inserted in the absence of an explicit value in an insert / update statement. Lets assume, your DDL

python - returning a default value

好久不见. 提交于 2019-11-27 09:16:28
I'm looking to mimic the behavior of built-in functions (like getattr ) that allow the user to specify a "default" return value. My initial attempt was to do this def myfunc(foo, default=None): # do stuff if (default is not None): return default raise SomeException() The problem is that if the users wants None to be their return value, this function would instead raise an exception. second attempt: def myfunc(foo, **kwargs): # do stuff if ('default' in kwargs): return kwargs['default'] raise SomeException() This addresses the above issue and allows the user to specify any arbitrary value, but

How to create default value for function argument in Clojure

自作多情 提交于 2019-11-27 09:14:47
问题 I come with this: (defn string->integer [str & [base]] (Integer/parseInt str (if (nil? base) 10 base))) (string->integer "10") (string->integer "FF" 16) But it must be a better way to do this. 回答1: A function can have multiple signatures if the signatures differ in arity. You can use that to supply default values. (defn string->integer ([s] (string->integer s 10)) ([s base] (Integer/parseInt s base))) Note that assuming false and nil are both considered non-values, (if (nil? base) 10 base)

AngularJS directive with default options

老子叫甜甜 提交于 2019-11-27 09:12:15
问题 I'm just starting with angularjs, and am working on converting a few old JQuery plugins to Angular directives. I'd like to define a set of default options for my (element) directive, which can be overridden by specifying the option value in an attribute. I've had a look around for the way others have done this, and in the angular-ui library the ui.bootstrap.pagination seems to do something similar. First all default options are defined in a constant object: .constant('paginationConfig', {

Setting the default value of a C# Optional Parameter

余生长醉 提交于 2019-11-27 09:01:39
Whenever I attempt to set the default value of an optional parameter to something in a resource file, I get a compile-time error of Default parameter value for 'message' must be a compile-time constant. Is there any way that I can change how the resource files work to make this possible? public void ValidationError(string fieldName, string message = ValidationMessages.ContactNotFound) In this, ValidationMessages is a resource file. No, you will not be able to make the resource work directly in the default. What you need to do is set the default value to something like null and then do the

Creating (and Accessing) a Sparse Matrix with NA default entries

こ雲淡風輕ζ 提交于 2019-11-27 07:40:57
After learning about the options for working with sparse matrices in R , I want to use the Matrix package to create a sparse matrix from the following data frame and have all other elements be NA . s r d 1 1089 3772 1 2 1109 190 1 3 1109 2460 1 4 1109 3071 2 5 1109 3618 1 6 1109 38 7 I know I can create a sparse matrix with the following, accessing elements as usual: > library(Matrix) > Y <- sparseMatrix(s,r,x=d) > Y[1089,3772] [1] 1 > Y[1,1] [1] 0 but if I want to have the default value to be NA, I tried the following: M <- Matrix(NA,max(s),max(r),sparse=TRUE) for (i in 1:nrow(X)) M[s[i],r[i]

JQuery ajax call default timeout value

不打扰是莪最后的温柔 提交于 2019-11-27 07:21:46
I got a bug report that I can't duplicate, but ajax-call timeout is the current best guess. So I'm trying to find out the default value for timeout of a jQuery $.ajax() call. Anybody have an idea? Couldn't find it in jQuery documentation. Thanks in advance, Marcus There doesn't seem to be a standardized default value. I have the feeling the default is 0 , and the timeout event left totally dependent on browser and network settings. For IE, there is a timeout property for XMLHTTPRequests here . It defaults to null, and it says the network stack is likely to be the first to time out (which will

C++11: template parameter redefines default argument

左心房为你撑大大i 提交于 2019-11-27 06:51:19
问题 When compiling the following source code with gcc there are no errors / warnings: template< typename T = int > T func( ); template< typename T = int > T func( ); When I compile the same source code with clang++, I got the following error: redeftempparam.cc:2:24: error: template parameter redefines default argument template< typename T = int > T func( ); ^ redeftempparam.cc:1:24: note: previous default template argument defined here template< typename T = int > T func( ); ^ 1 error generated.

JAXB objects initialized with default values

丶灬走出姿态 提交于 2019-11-27 06:45:32
问题 There is little problem with JAXB. Given: Java 1.5; jaxb -jars from jaxws-2_0. .xsd scheme and generated JAXB classes. Every simple element in .xsd has default value. And as result class members has annotations like " @XmlElement(name = "cl_fname", required = true, defaultValue = "[ _ __ _ __]") " Required Get java object (root element) which fully represent xml and every member initialized by default values. when I try to marshall xml without explicitly setting values, default values doesn't