+ Start a Discussion
streetstreet 

document.getElementById

How to call inputfield value which is in page block from javascript.

 

function test()

{

var end_date=document.getElementById(ttt);

}

 

 

<apex:column headerValue="Value1" id="e">

<apex:inputfield id="ttt" value="{!Is_rate}" >
</apex:inputfield>

TheIntegratorTheIntegrator

Its not very clear on what you want, but if you are trying to ask how to call you js function test, you can do that using onchange

 

<apex:inputfield id="ttt" value="{!Is_rate}" onchange="test();" >
</apex:inputfield>

streetstreet

i want to display visualforce page value in a alert box. 

 

i.e  value of input field where its id="ttt" , this value should be displayed in a alert box. on any events..

Navatar_DbSupNavatar_DbSup

Hi,


You have to mention either the entire path inside the document.getElementbyId like below:
1. <script> var theText = document.getElementById(“pageid:formid:ttt”); </script>

2. Or you can use Global variable Component like below:
<script> var theText = document.getElementById(“{!$Component.theText}”); </script>

TheIntegratorTheIntegrator

street wrote:

i want to display visualforce page value in a alert box. 

 

i.e  value of input field where its id="ttt" , this value should be displayed in a alert box. on any events..


You can simply do that by using alert inline

 

<apex:inputfield id="ttt" value="{!Is_rate}" onkeyup="alert(this.value);" >
</apex:inputfield>

 

if you want just on change

<apex:inputfield id="ttt" value="{!Is_rate}" onchange="alert(this.value);" >
</apex:inputfield>

*rdinakaran**rdinakaran*

<apex:inputfield id="ttt" value="{!Is_rate}" ></apex:inputfield>

 

function test()

{

var end_date=document.getElementById("{!$Component.ttt}");

}

alert('end_date'+end_date);

 

It Will Work,Let me know it solved your problem