I have 3 radio buttons in my visaulforce page, and 2 text fields. When I click the first radio button, at that time the first text field should be displayed. When I click the second radio button, the second field should be displayed. When I click the third radio button, again, the second field should be displayed. I am using javascript to hide/show the text fields but it's not working. Can anyone please give me a suggestion?
<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>
VF Page
<apex:pageBlockSection>
<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>