Reputation: 2722
Having one of those moments, why doesn't the below example work? When the user double clicks in the textarea, I want the text to be converted to upper case.
<textarea id="property_summary" name="property_summary" rows="5" cols="70" class="countcharacters" data-limit="1000" data-report="summary_cc" ondblclick="property_summary.value.toUpperCase();" required>This is test text</textarea>
Upvotes: 0
Views: 198
Reputation: 5428
ondblclick="property_summary.value.toUpperCase();"
isn't changing the content of the textarea. Rather, set the value of the textarea by setting the value
of this
, because this
represents the textarea in this context.
Thus, to fix this problem, simply set ondblclick="this.value = this.value.toUpperCase();"
.
<textarea ondblclick="this.value = this.value.toUpperCase();">This is test text</textarea>
Upvotes: 1
Reputation: 16297
You'll need to set the value like so: this.value = this.value.toUpperCase();
<textarea id="property_summary" name="property_summary" rows="5" cols="70" class="countcharacters" data-limit="1000" data-report="summary_cc" ondblclick="this.value = this.value.toUpperCase();" required>This is test text</textarea>
Upvotes: 2
Reputation: 57703
property_summary.value.toUpperCase()
is not an assignment.
Try
this.value = this.value.toUpperCase();
Upvotes: 3