You need to sign in to do that
Don't have an account?
Sujendran Sundarraj 8
onchange event for selectlist using jquery
Hi,
I have an requirement that I need to pass the value of the selectlist to my controller using jquery, I tried to get the value once it is selected from the list but it is not working. here is my code, can you please help to fix it.
<apex:page controller="selectoptionsz" >
<script type="text/javascript" src="//code.jquery.com/jquery-2.2.4.min.js"></script>
<script type="text/javascript" src="//cdnjs.cloudflare.com/ajax/libs/chosen/1.8.3/chosen.jquery.min.js"></script>
<apex:form >
<apex:selectList id="column1" size="1" value="{!c.Answer__c}">
<apex:selectOptions value="{!options}" />
</apex:selectList>
</apex:form>
<script>
$(document).ready(function(){
alert('success');
$('#column1').change(function(){
alert('test');
});
});
</script>
</apex:page>
Thank you.
regards,
Sujendran
I have an requirement that I need to pass the value of the selectlist to my controller using jquery, I tried to get the value once it is selected from the list but it is not working. here is my code, can you please help to fix it.
<apex:page controller="selectoptionsz" >
<script type="text/javascript" src="//code.jquery.com/jquery-2.2.4.min.js"></script>
<script type="text/javascript" src="//cdnjs.cloudflare.com/ajax/libs/chosen/1.8.3/chosen.jquery.min.js"></script>
<apex:form >
<apex:selectList id="column1" size="1" value="{!c.Answer__c}">
<apex:selectOptions value="{!options}" />
</apex:selectList>
</apex:form>
<script>
$(document).ready(function(){
alert('success');
$('#column1').change(function(){
alert('test');
});
});
</script>
</apex:page>
Thank you.
regards,
Sujendran
Apex tags generate dom ID so your onchange will not bind to your element. You can try giving customclass to your element and use it as css selector.
Hope this helps.
Thank you so much. Can you please help to pass the selected value to the controller and I my controller I need to query based on the selected value and show the result in another picklist.
Do you have any documents related to this.
Thank you once again.
Regards,
Sujendran.
Hope this helps.
Hope this will help.
try this below code:-
I have done this and it runs fine and change it according to your need.
<apex:page>
<script>
function displaydiv(val)
{
alert(val);
}
</script>
<apex:form>
<apex:selectList id="chooseColor" onchange="displaydiv(this.value)" size="1">
<apex:selectOption itemValue="value1" itemLabel="value 1" />
<apex:selectOption itemValue="value2" itemLabel="value 2" />
<apex:selectOption itemValue="value3" itemLabel="value 3" />
</apex:selectList>
</apex:form>
</apex:page>
I hope you find the above solution helpful. If it does, please mark as Best Answer to help others too.
Thanks and Regards,
Deepali Kulshrestha
Try the below code it works fine for me and let me know if this works for you.
I hope you find the above solution helpful. If it does, please mark as Best Answer to help others too.
Thanks,
Ajay Dubedi