Function is not defined

rss

Posted by schuess - Jun 11 ’14 at 03:29

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

 

 

 

  • Dmitry Kozlov
    Dmitry Kozlov
    Admin
    Member for: 6 years 2 months 20 days
    #1 by Dmitry Kozlov Jun 12 ’14 at 03:25

    Hello,

    Please, define your function globally:

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

    Now, you can use it in OnClick handler.

  • schuess
    schuess
    Member
    Member for: 5 years 10 months 16 days
    #2 by schuess Jun 12 ’14 at 08:08

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

  • schuess
    schuess
    Member
    Member for: 5 years 10 months 16 days
    #3 by schuess Jun 12 ’14 at 08:36

    UPDATE

     

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

     

    On site: http://formsdesigner.blogspot.com/2013/04/getting-and-setting-sharepoint-form.html

    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
    Member
    Member for: 5 years 10 months 8 days
    #4 by eedoh Jun 12 ’14 at 08:36

    if that's a textbox control, you're missing .control(), before .value(). Take a look at the following link

     

    http://formsdesigner.blogspot.com/2013/04/getting-and-setting-sharepoint-form.html

Displaying 1 to 4 of 4 messages