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
giri rockzzzzgiri rockzzzz 

Problem in fetching value of apex input text in javascript.....

can anyone help on this issue?????

 

<script>

function test()

{

 

var a=document.getElementById('{!$Component.r_3}').value;

 

}

 

</script>

 

<apex:form>

 

  <apex:inputText value="{!revenue3}" id="r_3"  />

<input value=" "  onfocus="test();" />

 

</apex:form>

Best Answer chosen by Admin (Salesforce Developers) 
Imran MohammedImran Mohammed

Did you try to alert and see what is shown.

 

Do the following,

Add id to form tag and all the parent tags of apex:inputText tag.

Then navigate from form id thorugh apex:inputText  id

for ex:

<script type="text/javascript">

function test()

{

 

var a=document.getElementById('{!$Component.formid.r_3}').value;

 

}

 

</script>

<form id="formid">

<apex:inputText id="r3"    ..... />

</form>

All Answers

Imran MohammedImran Mohammed

Did you try to alert and see what is shown.

 

Do the following,

Add id to form tag and all the parent tags of apex:inputText tag.

Then navigate from form id thorugh apex:inputText  id

for ex:

<script type="text/javascript">

function test()

{

 

var a=document.getElementById('{!$Component.formid.r_3}').value;

 

}

 

</script>

<form id="formid">

<apex:inputText id="r3"    ..... />

</form>

This was selected as the best answer
giri rockzzzzgiri rockzzzz

thank you....