javascript - How can I add alert button to the radio option if I have multiple select tags with same option?

Solution:

function selectfun(elem){
if(elem.value == 'radio'){
    alert(elem.value);
}
else{
    alert('it is not radio')
    }
}
 <select name='choose' class='choose' onclick='selectfun(this)'>
 <option value='text'>VAR CHAR</option>
 <option value='number'>NUMBER</option>
 <option value='radio'>RADIO</option>
 </select>
  <select name='choose' class='choose' onclick='selectfun(this)'>
 <option value='text'>VAR CHAR</option>
 <option value='number'>NUMBER</option>
 <option value='radio'>RADIO</option>
 </select>

Answer

Solution:

Add an event value to the onchange event
(I assume you want the selected value not that the select has been clicked)

<select id='select1' name='choose' class='choose' onchange=selectfun(event);>
    <option value='text'>VAR CHAR</option>
    <option value='number'>NUMBER</option>
    <option value='radio'>RADIO</option>
</select>

<select id='select2' name='choose' class='choose' onchange=selectfun(event);>
    <option value='text'>VAR CHAR</option>
    <option value='number'>NUMBER</option>
    <option value='radio'>RADIO</option>
</select>

<select id='select3' name='choose' class='choose' onchange=selectfun(event);>
    <option value='text'>VAR CHAR</option>
    <option value='number'>NUMBER</option>
    <option value='radio'>RADIO</option>
</select>

Get selection info using the event

function selectfun(event){
    alert(event.target.id + " Selected " +  event.target.value);
}

I added an ID to each select in this example so you can see from the output that it is the value from that specific select.

Issue
Only issue with this is if VAR CHAR is selected no change will occur so the function won't be fired.

Solution
I suggest adding an option that is an unset position that asked for a selection.

<select id='select1' name='choose' class='choose' onchange=selectfun(event);>
    <option value=''>SELECT VALUE</option>
    <option value='text'>VAR CHAR</option>
    <option value='number'>NUMBER</option>
    <option value='radio'>RADIO</option>
</select>

Source