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
akousikaakousika 

problem at retriving the inputText ID to script from Vf page

<apex:page controller="EditPage3" showHeader="FALSE" sidebar="False" id="thepage" >
<script language="javascript">
function fun()
{
alert("Hi");
alert("got it"+document.getElementById("thepage:FirstForm:revpanel:rev1").value);
alert("gone");
}


</script>
    <apex:form id="FirstForm">
        <apex:pageBlock id="blok" >
             <apex:pageBlockButtons location="Top">
                <apex:commandButton value="Save" action="{!saveall}"/>
              </apex:pageBlockButtons>   
             &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
            &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;            
            &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;            
               Select Year: <apex:selectList value="{!SelecedDateValue}"  onchange="myfunction();fun();"  size="1">                     
                    <apex:selectOptions value="{!Dateoptions}" />
                </apex:selectList>
                <apex:actionFunction name="myfunction" action="{!doProcess}" rerender="FirstForm" status="myStatus"/>
                 <apex:outputPanel id="thePanel" rendered="{!showpannel}">                     
                     <apex:inputText value="{!value1}" id="val1" style="height:15px;font-size:12px;" style="width:8%"/>                     
                     <apex:inputText value="{!value2}" id="val2" style="height:15px;font-size:12px;" style="width:8%"/>                     
                     <apex:inputText value="{!value3}" id="val3" style="height:15px;font-size:12px;" style="width:8%"/>                     
                     <apex:inputText value="{!value4}" id="val4" style="height:15px;font-size:12px;" style="width:8%"/>                     
                     <apex:inputText value="{!value5}" id="val5" style="height:15px;font-size:12px;" style="width:8%"/>                     
                     <apex:inputText value="{!value6}" id="val6" style="height:15px;font-size:12px;" style="width:8%"/>                     
                     <apex:inputText value="{!value7}" id="val7" style="height:15px;font-size:12px;" style="width:8%"/>
                </apex:outputPanel>                
        </apex:pageBlock>
        <div id="show">
        <table>
        <tr><td>
        <apex:selectList value="{!Metric1}" size="1" onchange="Metric1fun()">
            <apex:selectOptions value="{!Metri1options}"/>
        </apex:selectList>
        <apex:actionFunction name="Metric1fun" action="{!Metric1funProcess}" status="myStatus"/>
        
         <apex:outputPanel id="revpanel" rendered="{!revpanel}" >         
            <apex:inputText value="{!rev1}" id="rev1" style="height:15px;font-size:12px;" style="width:8%"/>                     
            <apex:inputText value="{!rev2}" style="height:15px;font-size:12px;" style="width:8%"/>                     
            <apex:inputText value="{!rev3}" style="height:15px;font-size:12px;" style="width:8%"/>                     
            <apex:inputText value="{!rev4}" style="height:15px;font-size:12px;" style="width:8%"/>                     
            <apex:inputText value="{!rev5}" style="height:15px;font-size:12px;" style="width:8%"/>                     
            <apex:inputText value="{!rev6}" style="height:15px;font-size:12px;" style="width:8%"/>                     
            <apex:inputText value="{!rev7}" style="height:15px;font-size:12px;" style="width:8%"/>                     
            <apex:inputText value="{!rev8}" style="height:15px;font-size:12px;" style="width:8%"/>                     
        </apex:outputPanel>

         <apex:outputText value="Watch this counter: {!count}" id="counter"/>
        <apex:actionStatus startText=" (incrementing...)"
            stopText=" (done)" id="counterStatus"/>
        <apex:actionPoller action="{!incrementCounter}" rerender="counter"
            status="counterStatus" interval="15"/>


.

.

.

 

.

 

.

.

 

//some code.

.

.

.

 

.

.

    </apex:form>
</apex:page>

 

********************************************************************************************************************************

 

As i am new to apex, Kindly sugest a solution for this ASAP.

 

Thanks & Worm Regards

Adithya K

hisrinuhisrinu

You can view the source code and figure out what is the component id... so that you can pass the same id and then get the value in java script

Pradeep_NavatarPradeep_Navatar

It seems that the error is in reference the inputtext id. Tryout this following syntax :

 

Remove the outputpanel id from the syntax.

JS  Code: document.getElementById("thepage:FirstForm:rev1").value

 

Hope this helps.

aballardaballard

You should always use $component to obtain the DOM id of a field from the id attribute specified in the markup, instead of trying to reverse-engineer what is generated by visualforce. 

 

However you may have to put the code that references $Component in the right context in the page to get the correct value.

 

There are lots of examples in other posts and in the doc.