You need to sign in to do that
Don't have an account?

Radio Button Click is not working
HI,
I have 3 radio buttons in my visaulforce page, and 2 text fields, when i click 1st radio button at that time 1st text field will be display, when i click 2nd Radio button 2nd Field will be display, when i click 3rd Radio Button again 2nd radio button will be display, i am using javascript for hide/show the text fields but it's not working can any one give me suggestions.
JavaScript--
<script type="text/javascript">
function show(t)
{
if ( t.value == 0 )
{
document.getElementById("defaultcost").style.display = 'block';
document.getElementById("differcost").style.display = 'none';
}else{
document.getElementById("defaultcost").style.display = 'none';
document.getElementById("differcost").style.display = 'block';
}
}
</script>
<apex:selectRadio value="{!Quote__c.shipping_type__c}" onChange="show(this);">
<apex:selectOption itemLabel="Use Store Settings" itemValue="0" />
<apex:selectOption itemLabel="Per Item" itemValue="1" />
<apex:selectOption itemLabel="Fixed Price Per Order" itemValue="2" />
</apex:selectRadio>
<apex:inputField value="{!Quote__c.storeprice__c}" id="defaultcost" style="display:block;"/><br/>
<apex:inputField value="{!Quote__c.price__c}" id="differcost" style="display:none;"/><br/>
</apex:pageBlockSection>
I have 3 radio buttons in my visaulforce page, and 2 text fields, when i click 1st radio button at that time 1st text field will be display, when i click 2nd Radio button 2nd Field will be display, when i click 3rd Radio Button again 2nd radio button will be display, i am using javascript for hide/show the text fields but it's not working can any one give me suggestions.
JavaScript--
<script type="text/javascript">
function show(t)
{
if ( t.value == 0 )
{
document.getElementById("defaultcost").style.display = 'block';
document.getElementById("differcost").style.display = 'none';
}else{
document.getElementById("defaultcost").style.display = 'none';
document.getElementById("differcost").style.display = 'block';
}
}
</script>
<apex:selectRadio value="{!Quote__c.shipping_type__c}" onChange="show(this);">
<apex:selectOption itemLabel="Use Store Settings" itemValue="0" />
<apex:selectOption itemLabel="Per Item" itemValue="1" />
<apex:selectOption itemLabel="Fixed Price Per Order" itemValue="2" />
</apex:selectRadio>
<apex:inputField value="{!Quote__c.storeprice__c}" id="defaultcost" style="display:block;"/><br/>
<apex:inputField value="{!Quote__c.price__c}" id="differcost" style="display:none;"/><br/>
</apex:pageBlockSection>
Please review the links below on how to use javascript or hide/show the text fields:
1.http://stackoverflow.com/questions/17621515/how-to-show-and-hide-input-fields-based-on-radio-button-selection
2.http://stackoverflow.com/questions/18758402/js-show-hide-text-field-depending-on-radio-button-issue
3.http://bytes.com/topic/javascript/answers/148302-display-hide-fields-using-radio-buttons
4.http://www.chronoengine.com/forums/posts/f26/t95043.html
5.http://arstechnica.com/civis/viewtopic.php?f=20&t=594144
6.http://stackoverflow.com/questions/362614/calling-onclick-on-a-radiobutton-list-using-javascript
7.http://stackoverflow.com/questions/10747521/using-javascript-onclick-to-style-currently-selected-radio-button
8.http://www.dyn-web.com/tutorials/forms/radio.php
9.http://www.codeproject.com/Questions/204763/hide-show-text-box-using-radio-button
I hope this information has been helpful. If this has helped resolve your issue, please let us know by marking the post as ""Best Answer"" to help others in the community with similar questions.