Function is not defined

Discussions about Forms Designer for SharePoint 2013 / 2016 and Office 365.
Locked
User avatar
schuess
Posts: 82
Joined: Wed Jan 22, 2014

11 Jun 2014

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

User avatar
Dmitry Kozlov
Site Admin
Posts: 1524
Joined: Thu Jun 07, 2012

12 Jun 2014

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.

User avatar
schuess
Posts: 82
Joined: Wed Jan 22, 2014

12 Jun 2014

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();
//}

User avatar
schuess
Posts: 82
Joined: Wed Jan 22, 2014

12 Jun 2014

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();

eedoh
Posts: 37
Joined: Tue Feb 11, 2014

12 Jun 2014

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

Locked
  • Information
  • Who is online

    Users browsing this forum: No registered users and 11 guests