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
krishna1krishna1 

when command link click inputText box value change using javascrip

Hi,

 

when click command link or anchor link input text box value changed using javascriipt?

 

Thanks

Best Answer chosen by Admin (Salesforce Developers) 
Deepa.B.AnkaliDeepa.B.Ankali

@krishna1,

 

Here is a rough idea on developing this:

 

1. <apex:commandLink value="Click Me" onClick="return JSMethod();" rerender="idTextBox"/> 
2. <apex:inputText value="{!xyz}" id="newValueId"/>	(New Value from User)
3. <apex:inputText value="{!abc}" id="idTextBox"/>	(Text box whose value you want to change)
4.	<script>
		function JSMethod()
		{
			var newValue = document.getElementById('{!$Component.newValueId}').value;
			document.getElementById('{!$Component.idTextBox}').value = newValue;
		}
	</script>

 

All Answers

Deepa.B.AnkaliDeepa.B.Ankali
@krishna1,

1. Use commandLink attribute, 'onClick'.
2. Call Javascript function onClick
3. Document.getElementById(TEXTBOXID).value = NEW VALUE.
4. Rerender that block containing text box.
krishna1krishna1

Hi DeepaAnika,

 

Thank you for replay, Please give me one example, very usefull.

 

Thanks

Deepa.B.AnkaliDeepa.B.Ankali

@krishna1,

 

Here is a rough idea on developing this:

 

1. <apex:commandLink value="Click Me" onClick="return JSMethod();" rerender="idTextBox"/> 
2. <apex:inputText value="{!xyz}" id="newValueId"/>	(New Value from User)
3. <apex:inputText value="{!abc}" id="idTextBox"/>	(Text box whose value you want to change)
4.	<script>
		function JSMethod()
		{
			var newValue = document.getElementById('{!$Component.newValueId}').value;
			document.getElementById('{!$Component.idTextBox}').value = newValue;
		}
	</script>

 

This was selected as the best answer
krishna1krishna1

Thank you DeepaAnika