Page 1 of 1

Function is not defined

Posted: 11 Jun 2014
by schuess
I have the following function in my javascript


function myFunc(){
var myURL = fd.field('urlOfMeetMin').value();
//alert(myURL)
window.location.href= myURL;
}


I added a button to the form, and in the Onclick config box i put


myFunc();


Error: myFunc is not defined

Re: Function is not defined

Posted: 12 Jun 2014
by Dmitry Kozlov
Hello,

Please, define your function globally:

Code: Select all

window.myFunc = function(){
var myURL = fd.field('urlOfMeetMin').value();
//alert(myURL)
window.location.href= myURL;
}
Now, you can use it in OnClick handler.

Re: Function is not defined

Posted: 12 Jun 2014
by schuess
Thank you, that worked.


I just can not seem to grab the value of the field: fd.field('urlOfMeetMin').value(); Keeps returning undefined.


//window.myFunc = function(){
//var myURL = fd.field('urlOfMeetMin').value();
//alert(myURL)
//window.location.href= myURL;
//}

//window.myFunc = function(){
//window.location.href =fd.field('urlOfMeetMin').value();
//}

Re: Function is not defined

Posted: 12 Jun 2014
by schuess
UPDATE


i got it to work, but it was the documentation that was throwing me off


On site: http://spform.com/forms-designer- ... eld-values

It says use this to get a fields value: fd.field('Title').value();

But really this is what works. fd.field('Title').control()._el().text();

Re: Function is not defined

Posted: 12 Jun 2014
by eedoh
if that's a textbox control, you're missing .control(), before .value(). Take a look at the following link

http://spform.com/forms-designer- ... eld-values