I have wrote a java script to replace the value of email field to "user name" same time when user tying in the email field and I hided the username field.
Used string builder to render the script
function change(){
var Email=document.getElementByID('#Email');
var UserName=document.getElementByID('#UserName);
UserName.value=Email.Value;
}
the above code is working only when I add the webpart inside sharepoint page,but when I added the web part on an application page the UserName field is not getting updated when email field is typed.
when checked browser debugging I cant see the java script in that application page .
can I how to work this is application page ,Do I need to copy the same script to the application page where I added the webpart?
Thanks
There was two problems here, the first, getElementById wasn't written well and second, value property is lowercase.
function change(){
var Email = document.getElementById('#Email');
var UserName=document.getElementById('#UserName');
UserName.value=Email.value;
}
Issue 1 : it should be "getElementById" not getElementByID
Issue 2 : The id should not have # until and unless you are using the ID that has #(sounds silly to use # in Id)
Issue 3 : it should be "value" not Value
Use an IDE like visual studio and you will not get these silly errors.
Related
I created a button in an account form entity by ribbon workbench and then I tried to create a javascript code. When executed the code is just fetching the account id and showing that id in the alert and then I registered that file to that button by ribbon workbench action command.
I wrote the below code, please let me know what is wrong with that.
I am expecting an alert box with that id, but nothing is happening
The code is below:
fetch = {
fetchingacountid: function(executionContext){
var formContext = Xrm.Page.context.getFormContext();
var accountId = formContext.data.entity.getId();
alert("The ID of the current account is: " + accountId);
}
}
Possibly you might have missed to add the PrimaryControl CRM parameter in ribbon command. Then you don’t need Xrm.Page, instead you will get the context directly in the first parameter executionContext. Read more
I have a problem with my mobile app using Cordova. I have a strings.js, this file contains all strings used in the app in 2 languages for example :
kStrings["fr"]["skip"] = "passer";
kStrings["en"]["skip"] = "skip";
when I need this string for example I call it like this :
{#skip#}
the problem is when the page is loaded or when I click on this link the text value change to:
{#skip#}
Any ideas?
this error comes up when using the following :
field otherinfo has id=idOtherInfo and is declared in a .xml file under Models, Forms in joomla.
The field has a default value in the declaration to prevent the null (shows the default value in the browser) and using the
onchange="dosomething()"
I am running a javascript file, which runs ok as it shows an alert and then it halts on the command
var first1 = document.getElementById("idOtherInfo").value;
The javascript file is loaded by
JHtml::script(JURI::root() . 'media/com_hr/js/validateFields.js', true);
also can be loaded by
$document = JFactory::getDocument();
$document->addScript(JURI::root().'media/com_hr/js/validateFields.js');
Can you please help?
Thanks
It means that element with ID idOtherInfo dosen't exist. Check your source code of web page to be sure that it shows your input correctly.
SOLUTION
If Joomla! generates forms from XML file, it adds jform_ to start of input and label ID and -lbl to end of label.
So for getting input value
var first1 = document.getElementById("jform_idOtherInfo").value;
and for label
var first1 = document.getElementById("jform_idOtherInfo-lbl").innerHTML;
This could be a long shot but I think you've had a little mix up with the name of the ID. Try changing this:
document.getElementById("idOtherInfo").value;
to this:
document.getElementById("OtherInfo").value;
I am using LoadRunner true client AJAX protocol for recording purpose.
I have successfully recorded the script and tried to create a parameter in a table (text file) containing username and password as column names.
The text file has a name username by itself.
In the Vuser script when I create a JavaScript variable like this:
login_name=LR.getParam("username")
I replaced the username with above parameter and it works fine, but for password I am not able to create a separate variable to pass. It is passing the same username into password box and login fails.
What is my mistake, what do I need to change in the parameter list to update the password?
loadrunner encrypts the password by default look for lr_decrypt in the script , right click on the argument inside this function and select restore original value .
now select the restored value and parametrise it. it works:)
I have some very simple code that is triggered by a google form (see http://goo.gl/lFHi3j) that asks for 2 email addresses. The code works fine when the email address is hardcoded (see commented email below) but when I try and obtain the email using e.values (when the form is submitted) is get the following error
Execution failed: TypeError: Cannot read property "1" from undefined.
(line 3, file "Code").
I've searched this forum but can't find a solution to this problem. Can anyone please help.
function onFormSubmit (e) {
// var email_address_ = "pian1966#gmail.com";
var email_address_ = e.values[1];
// Send the email
var subject_ = "Andy's Report";
var body_ = "Here is Andy's report...";
MailApp.sendEmail(email_address_, subject_, body_, {htmlBody: body_});
}
There is no e.values[1].
That is the answer to the question as to why you are getting that error.
Do a console.log(e) and familiarize yourself with what e consists of by looking at the log results in a browser debugger.
From there you can determine for yourself if e.values even exists as an array. Then go from there.
Thanks for the responses which all helped me find a solution to the problems I was having. Here's what I've discovered as I've worked on a solution:
The Google App Script must be created (as a blank script) from
responses spreadsheet and NOT out of the form itself!
In Google Forms, the developer has the option of unlinking their
responses spreadsheet and sending responses to new results
spreadsheet. If this option is selected then a new script needs to
be created from the new results spreadsheet and the code must be
copied/moved into the new script. Of course this means that a new
trigger must be created and the script needs to be authorized to
run.
Once a user submits a form, they can be given the option to
edit/correct their submission. Unless EVERY field is edited, the
script thinks the unedited fields are blank and writes "undefined"
into the resulting Google Doc. I've therefore disabled the "Edit"
option in my form to get around this.
If the user skips over irrelevant fields (leaves them blank) then
the e.values numbering order is thrown out. I have therefore made
every field compulsory with the comment that the user enter 'n/a' if a
field doesn't apply.
Having worked through these issues my form now works perfectly (albeit a little clumsily with all questions being compulsory). I would be very grateful if anyone has any suggestions on how to get around the Editing and and Blank Field problems.
(Thanks to TJ Houston for his original script)