You need to sign in to do that
Don't have an account?
Michael Rotter
Update a text input field using javascript
I'm trying to update the data in an input text field using a button and javascript. I've tried using document.getElementByID but i get an error saying that isn't a function. Here is my code so far:
document.getElementByID("Case.Subject").value="Does this work?";
function CopySubject() {
var a = "{!Case.Subject}";
alert(a);
}
function CopyCN() {
var b = "{!Case.CaseNumber}";
alert(b);
}
CopySubject();
CopyCN();
Essentially, my code should put "Does this work?" into the subject of the case and then put out messages that contain the subject and case number. Any help is greatly appreciated!
document.getElementByID("Case.Subject").value="Does this work?";
function CopySubject() {
var a = "{!Case.Subject}";
alert(a);
}
function CopyCN() {
var b = "{!Case.CaseNumber}";
alert(b);
}
CopySubject();
CopyCN();
Essentially, my code should put "Does this work?" into the subject of the case and then put out messages that contain the subject and case number. Any help is greatly appreciated!
document.getElementByID("Case.Subject").value="Does this work?"; this is not going to work
refere this code:-
<apex:inputText id="CaseSubject" value="{!Case.Subject}"></apex:inputText>
<script>
function CopySubject() {
var CaseSub= $('[id$=CaseSubject]').val();
alert(CaseSub);
}
</script>
You have to call CopySubject(); this function on click of any button
Thanks,
Atul Patil
Salesforce Developer
www.zen4orce.com
Thanks for the reply and the suggestions. Is there a way to do it completely in javascript tho? The only scriptable action option on the edit button page doesn't recognize the html syntax.
Thanks!
Use input field and then call function from javascript on button click, this is will update field value onClick
Enter New Value: <input type="text" id="myText" value="{!Case.Subject}">
<button onclick="myFunction()">Update Value</button>
<script>
function myFunction() {
document.getElementById("myText").value = "Does this work?";
}
</script>
Thank you,
Amol Salve
Salesforce Developer
You can also do this by using JQuery
Please refere this code :
Thanks,
Atul Patil
Salesforce Developer
www.zen4orce.com
I think there is some confusion goin over here.
Are you trying to achieve this in your VF page or using JavaScript button on the standard page ?
If you are using VF Page then -
If you are using JavaScript button then, in that case this is not achievable because you can't set ID on the input field of standard page.
Why I guessed that you might be using Javascript button, is because the code you have shared gives me a hint of JS button -
Thanks,
Mustafa Jhabuawala
Technica Lead at Zen4orce (http://www.zen4orce.com)
i tried your suggestion, i get this error
is there another way to do it?
I want my sf form to be green (showing that the edits have been made successfully)
I was thinking maybe something involving sfdcPage.inlineEditData("*id of text field*")
Please help, and please verify the process works for textbox and dropdown. thank you