You need to sign in to do that
Don't have an account?
prady
Getting value of field in java script
Hi,
I have aVF page where in i am trying to copy a outputtext value into prompt. The idea is to have an option to copy field values into clipboard.
The issue i am facing is that the value in javascript is coming as undefined.
first alert shows page1:txtaccid
the second alert shows undefined.
Any idea what could be the issue
<apex:page standardController="Account" sidebar="false" showHeader="false" id="page1"> <!-- Begin Default Content REMOVE THIS --> <script> function copyToClipid(textid) { alert(textid); alert(document.getElementById(textid).value); var copy_id= document.getElementById(textid).value; window.prompt ("Copy to clipboard: Ctrl+C, Enter", copy_id); } </script> Account : <apex:outputField value="{!account.id}" id="txtaccid"/> <input type="button" id="copyMe" class="btn" value="Copy to Clipboard" onclick="copyToClipid('{!$Component.txtaccid}');"/><br/> Account Name : <apex:outputField value="{!account.name}" id="txtaccname"/> <!-- End Default Content REMOVE THIS --> </apex:page>
Hi,
You can use document.getElementById(textid).innerHTML to get the account id from visual force component.
Did this answer your question? If not, let me know what didn't work, or if so, please mark it solved.