function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
RIteshMRIteshM 

onselect attribute is not working in apex:selectList

i write a visualforce page

 

<apex:page controller="sampleCon">
<apex:form>
<apex:selectList value="{!countries}" size="1" onselect="searchFeeds();">
<apex:selectOptions value="{!items}"/>
</apex:selectList>
<script type="text/javascript">
function searchFeeds(){
alert('Hello world');
}
</script>
<p/>
</apex:form>
<chatter:newsfeed />
</apex:page>

 

and controller code is 

 

public class sampleCon {
String countries ;

public PageReference test() {
return null;
}

public List<SelectOption> getItems() {
List<SelectOption> options = new List<SelectOption>();
options.add(new SelectOption('US','US'));
options.add(new SelectOption('CANADA','Canada'));
options.add(new SelectOption('MEXICO','Mexico'));
return options;
}

public String getCountries() {
return countries;
}
public void setCountries(String countries) {
this.countries = countries;
}
}

 

when i select any different country from select list no alert is shown by the browser. can any one please point me why ??

pinoytechiepinoytechie

try onchange, i.e.

<apex:selectList value="{!countries}" size="1" onchange="searchFeeds();">