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

Issue with javascript for inputText


I am trying to hide and display  a inputText field ,on change of a radio button,using javascript,but the issue is that,this is affecting only to the label of that text field,and no efffect on the text field.Please suggest me a solution



<script type="text/javascript">

function showVisibility(radio_value,id)



*********VF page **********

<label for="typical">4.Is this typical?</label>
<apex:selectRadio id="typical" onchange="showVisibility(this.value)" >
<apex:selectOption itemValue="0" itemLabel="Yes" />
<apex:selectOption itemValue="1" itemLabel="No" />

<div id="average_sales">
<label for="average_sales_price">4.1.what is the average sales price?</label>
<apex:inputText id="average_sales_price" label="4.1.what is the average sales price?"/>





Hi Shine,


The ElementId you are searching for will not work. Whatever ID you provide to element, salesforce changes it.

So if you want the elementId of the inputText field, use below sytax:


 You can read below few posts, which will throw light on this scenario:


Try to put that input text inside an outputpanel.


Rerender the outputpanel on click of the radio button.


On click of the radio button call an action function which in turns calls an apex method to show or hide the outputpanel.


Something like this:

In Page

on click of radio button call this action function-->

 <apex:actionFunction action="{!callMethod}" name="acFunct" reRender="testPanel"/>



 <apex:outputPanel id="testPanel" rendered="{!showInput}">
                         //input text


In controller

//to hide /show the input
    public boolean showInput{get;set;}

    public callMethod(){

        showInput =  false;