default-value

Delete default value of an input text on click

微笑、不失礼 提交于 2019-11-26 10:17:54
问题 I have an input text : <input name=\"Email\" type=\"text\" id=\"Email\" value=\"email@abc.com\" /> I want to put a default value like \"What\'s your programming question ? be specific.\" in StackOverFlow, and when the user click on it the default value disapear. 回答1: For future reference, I have to include the HTML5 way to do this. <input name="Email" type="text" id="Email" value="email@abc.com" placeholder="What's your programming question ? be specific." /> If you have a HTML5 doctype and a

namedtuple and default values for optional keyword arguments

人盡茶涼 提交于 2019-11-26 10:05:50
问题 I\'m trying to convert a longish hollow \"data\" class into a named tuple. My class currently looks like this: class Node(object): def __init__(self, val, left=None, right=None): self.val = val self.left = left self.right = right After conversion to namedtuple it looks like: from collections import namedtuple Node = namedtuple(\'Node\', \'val left right\') But there is a problem here. My original class allowed me to pass in just a value and took care of the default by using default values for

Nonstatic member as a default argument of a nonstatic member function

最后都变了- 提交于 2019-11-26 09:25:49
问题 struct X { X():mem(42){} void f(int param = mem) //ERROR { //do something } private: int mem; }; Can anyone give me just one reason as to why this is illegal in C++?! That is to say, I know that it is an error, I know what the error means, I just can\'t understand why would this be illegal! 回答1: Your code (simplified): struct X { int mem; void f(int param = mem); //ERROR }; You want to use a non-static member data as default value for a parameter of a member function. The first question which

Getting a default value on index out of range in Python [duplicate]

别等时光非礼了梦想. 提交于 2019-11-26 09:08:21
问题 This question already has an answer here: How to get the nth element of a python list or a default if not available 9 answers a=[\'123\',\'2\',4] b=a[4] or \'sss\' print b I want to get a default value when the list index is out of range (here: \'sss\' ). How can I do this? 回答1: In the Python spirit of "ask for forgiveness, not permission", here's one way: try: b = a[4] except IndexError: b = 'sss' 回答2: In the non-Python spirit of "ask for permission, not forgiveness", here's another way: b =

Why can&#39;t a text column have a default value in MySQL?

好久不见. 提交于 2019-11-26 09:06:05
问题 If you try to create a TEXT column on a table, and give it a default value in MySQL, you get an error (on Windows at least). I cannot see any reason why a text column should not have a default value. No explanation is given by the MySQL documentation. It seems illogical to me (and somewhat frustrating, as I want a default value!). Anybody know why this is not allowed? 回答1: Windows MySQL v5 throws an error but Linux and other versions only raise a warning. This needs to be fixed. WTF? Also see

std::map default value for build-in type

梦想与她 提交于 2019-11-26 08:25:25
问题 Recently, I was confused by the std::map operator[] function. In the MSDN library, it says: \"If the argument key value is not found, then it is inserted along with the default value of the data type.\" I tryed to search much more exactly explanation for this issue. For example here: std::map default value In this page, Michael Anderson said that \"the default value is constructed by the default constructor(zero parameter constructor)\". Now my quest comes to this:\"what the default value for

C# 4.0: Can I use a TimeSpan as an optional parameter with a default value?

ⅰ亾dé卋堺 提交于 2019-11-26 08:21:25
问题 Both of these generate an error saying they must be a compile-time constant: void Foo(TimeSpan span = TimeSpan.FromSeconds(2.0)) void Foo(TimeSpan span = new TimeSpan(2000)) First of all, can someone explain why these values can\'t be determined at compile time? And is there a way to specify a default value for an optional TimeSpan object? 回答1: You can work around this very easily by changing your signature. void Foo(TimeSpan? span = null) { if (span == null) { span = TimeSpan.FromSeconds(2);

What is the default value for C++ class members

断了今生、忘了曾经 提交于 2019-11-26 08:13:06
问题 What is the default values for members of a struct and members of a class in c++, and how do these rules differ (e.g. between classes/structs/primitives/etc) ? Are there circumstances where the rules about the default values differs ? 回答1: There are no differences between structs and classes in this regard in C++. They all are called just class types . Members of class types have no default values in general case. In order to for a class member to get a deterministic value it has to be

CURRENT_DATE/CURDATE() not working as default DATE value

倖福魔咒の 提交于 2019-11-26 07:40:45
问题 Pretty straight forward question here, I think this should work but it doesn\'t. Why doesn\'t it? CREATE TABLE INVOICE( INVOICEDATE DATE NOT NULL DEFAULT CURRENT_DATE ) 回答1: It doesn't work because it's not supported The DEFAULT clause specifies a default value for a column. With one exception, the default value must be a constant; it cannot be a function or an expression. This means, for example, that you cannot set the default for a date column to be the value of a function such as NOW() or

named PHP optional arguments?

百般思念 提交于 2019-11-26 06:46:57
问题 Is it possible in PHP 4/5 to specify a named optional parameter when calling, skipping the ones you don\'t want to specify (like in python) ? Something like: function foo($a,$b=\'\', $c=\'\') { // whatever } foo(\"hello\", $c=\"bar\"); // we want $b as the default, but specify $c Thanks 回答1: No, it is not possible : if you want to pass the third parameter, you have to pass the second one. And named parameters are not possible either. A "solution" would be to use only one parameter, an array,