I need to get a value from a javascript variable into a text field in a visualforce page.
I got it using a command button.But I was wondering if there is any other way of getting it,cz i dun want an onclick event.
Thanks in advance
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
I can’t tell by your comment what event you’re listening for, but assuming you know what that will be, just use document.getElementById() or a selector in jQuery to get the input field. If you are using Apex:inputField, define the id attribute with something like ‘theField’. When the page is rendered, Salesforce should give an id attribute like ‘j_id0:j_id1:theField’ to the real tag, but this can and probably will be different every time the page is viewed. That means you’re going to need to select the input by a substring. Here’s some sample code using jQuery (apologies to any jq gurus out there if it’s inefficient– feel free to improve).