Field returns undefined

rss

Posted by Phoenix - Feb 17 ’15 at 02:20

Hi there

 

I have a 'YesNo' Field and I would like to check if it is selected. I have following code:

fd.field('Other_x0020_baseware_x002d_users').readonly(false);

alert(fd.field('Other_x0020_baseware_x002d_users').value());

 

I do get undefined as alert...what did I do wrong?

  • Dmitry Kozlov
    Dmitry Kozlov
    Admin
    Member for: 6 years 10 months 16 days
    #1 by Dmitry Kozlov Feb 17 ’15 at 04:01

    Hi,

    Is it a new, edit, or display form? If the field is rendered in the read only mode, you should use the following code to get its value:

    fd.field('Other_x0020_baseware_x002d_users').control()._el().text()
    
  • Phoenix
    Member
    Member for: 5 years 7 months 29 days
    #2 by Phoenix Feb 17 ’15 at 06:45

    Thanks. It is in the Edit form. Should I then compare it with value 'yes' or 'no' order with boolean oder 0 and 1?

  • Dmitry Kozlov
    Dmitry Kozlov
    Admin
    Member for: 6 years 10 months 16 days
    #3 by Dmitry Kozlov Feb 18 ’15 at 04:33

    [#2]: Could you send HTML-source of your form page to [email protected]? Thanks!

  • Phoenix
    Member
    Member for: 5 years 7 months 29 days
    #4 by Phoenix Feb 18 ’15 at 07:19

    Hi

     

    It works perfect thanks. I compared it with 'Yes' an 'No'

  • Phoenix
    Member
    Member for: 5 years 7 months 29 days
    #5 by Phoenix Feb 18 ’15 at 07:28

    hi there..... I have a another problem with multiline rich textfield

    although I found this post in the forum it is not working for me.

     

    when i do the following:

     

    fd.field('Justification').control()._el().find('div.ms-rtestate-write').text().replace(/\W/g, '');

    if (!fd.field('Justification').control()._el().find('div.ms-rtestate-write').text()) {

    ....

    It will not enter the if statement when Justification is empty. When I add Trim.....it deletes all the text in Justification.... What did I do wrong?

     

     

  • Dmitry Kozlov
    Dmitry Kozlov
    Admin
    Member for: 6 years 10 months 16 days
    #6 by Dmitry Kozlov Feb 20 ’15 at 07:49

    [#5]: Please, make sure that you pass the correct internal name of the field into fd.field() method. Also ensure that the type of field is Rich Text, not Enhanced Rich Text or Plain Text.

  • Phoenix
    Member
    Member for: 5 years 7 months 29 days
    #7 by Phoenix Feb 20 ’15 at 08:01

    Hello Dimitry

     

    Thanks. I actually do use an enhance richt text field. It works now, when I use this code:

    var text = fd.field('Justification').control()._el().find('div.ms-rtestate-write').text().replace(/\W/g, '');

    if (text == '') {

    ...

    }

     

    Apparenty, I have to save the result of the method replace in a variable, otherwise it is not working...

Displaying 1 to 7 of 7 messages