Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

HTML onchange (this.value)

We found this in our code (we haven't written it by our selfs, and we are new to programmng), can anyone explain what this.value means and how you change it?

<select id="sel_target" onchange="paint(this.value);sendid(value); highlight(value);move_to(value)">

Thank you!

like image 821
e.klara.k Avatar asked Sep 09 '15 10:09

e.klara.k


People also ask

How do I pass value to Onchange?

To pass multiple parameters to onChange in React:Pass an arrow function to the onChange prop. The arrow function will get called with the event object. Call your handleChange function and pass it the event and the rest of the parameters.

Can I use Onchange on Div?

No; the onchange attribute is only applicable to form field elements ( input , select , textarea , etc).

What can I use instead of Onchange?

onBlur should be used instead of onChange , unless absolutely necessary and it causes no negative consequences for keyboard only or screen reader users.


1 Answers

this.value represents the selected value.

Example:

function getComboA(sel) {
    var value = sel.value;  
}

<select id="comboA" onchange="getComboA(this)">
<option value="">Select combo</option>
<option value="Value1">Text1</option>
<option value="Value2">Text2</option>
<option value="Value3">Text3</option>
</select>

The above example gets you the selected value OnChange event.

like image 166
SVK Avatar answered Sep 18 '22 18:09

SVK