You need to sign in to do that
Don't have an account?
mavs
Page validation
Hi
what am i doing wrong here??
I am trying to pass selected value of selectlist to javascript function in the commandLInk onclick event
when the command link is clicked, in the alert it is showing as undefined....
How to pass the selected list value here? Please advise
<apex:page controller="option_test"> <apex:form <apex:pageBlock> <apex:selectList id="ch" value="{!num}" multiselect="false" size="1"> <apex:selectOption itemValue="" itemLabel=""/> <apex:selectOption itemValue="01" itemLabel="01"/> <apex:selectOption itemValue="01" itemLabel="02"/> </apex:selectList> <apex:CommandLink onclick="return validate()">click</apex:CommandLink> <script language="javascript">
function validate()
{
try
{
alert("Hi "+document.getElementById("{!$Component.ch}").value)
return false;
}
catch(e)
{
alert(e);
return false;
}
}
</Script> </apex:pageBlock> </form> </page>
public class option_test { public String num{get;set;} }
I've tried your code in IE8, firefox and chrome and it works as expected once I'd fixed a couple of things:
thanks Bob..
It worked!!
question: it should be same for selectRadio as well correct? the code below for selectRadio isnt working
Please advise
hi - Any word on this?