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
JamesSSJamesSS 

Option value in inside of JS in Pageload

My code:

Class:

 

public class Jserrors{
public list<Selectoption> Performance{set; get;}
public Jserrors(){
Performance = pick();
}

public list<SelectOption> pick(){

op.add(new selectOption('Prospect','Prospect');
op.add(new selectOption('Customer-Direct','Customer-Direct');
op.add(new selectOption('Other','Other');
return op;
}

}

 

VF code:

<apex:page controller="Jserrors">
<apex:includeScript value="https://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js" />
<script>
$(function($) {
$('.Radios').each(function(){
var value = $(this).val();
alert('value'+value);
});
});
</script>
<apex:form >
<div>
<div style = "margin-bottom:10px;">Radios</div>
<div>
<apex:selectRadio layout="pageDirection" id = "radios" styleClass="Radios">
<apex:selectOptions value="{!Performance}"></apex:selectOptions>
</apex:selectRadio>
</div>
</div>
</apex:form>
</apex:page>

 

In mycode have returned empty option value in page load.Is it possible to return Performance option values in page load?

Best Answer chosen by Admin (Salesforce Developers) 
Avidev9Avidev9

Better!

 

 

Here you are 

(Salesforce renders the radios and applies class a lil diffrerent way.)

 

<script>
$(function($) {
   $('.Radios').find('input:radio').each(function(){
       alert(this.value);
   });
});
</script>

 

All Answers

Avidev9Avidev9
can you elaborate a lil ?
What due you mean by "return Performance option values in page load" ?
JamesSSJamesSS

Yes.I Need all three radio option(Performance option values)  values in page load.
My output is showing in alerts(3 times alerts).


value Prospect
value Customer-Direct
value Other

Avidev9Avidev9
I understand that you are getting 3 alerts .

But Still not clear!
what exactly you want ?

do you want them in one alert or something ?
JamesSSJamesSS

Avi, In page load, I want to get this all radio button option values in alerts.I have three selectoption values in controller.Now In script function i got the only one empty alert.But I want to get three option values in each alert by one by one in Script.Is it possibl?

Avidev9Avidev9

Better!

 

 

Here you are 

(Salesforce renders the radios and applies class a lil diffrerent way.)

 

<script>
$(function($) {
   $('.Radios').find('input:radio').each(function(){
       alert(this.value);
   });
});
</script>

 

This was selected as the best answer
JamesSSJamesSS

Hai Avi,

In that above code, How to check  I didn't select any select radio(throws error via alert ""please select any one option") in that options? Is it possible?