Search for string within a text fields

Comments

4 comments

  • Rainer Grabowski

    Hi Ottar,

    Podio calculation fields use Javascript, not PHP. :)

    I assume, the text ""Hello my registration number is XYZ123455" is in a text field.

    This script should get what you want (even if there is text behind the number): 

    var text = @your text field name;
    text.indexOf("XYZ") > -1 ? text.substring(text.indexOf("XYZ"),text.indexOf("XYZ")+9) : ""

    If XYZ is in the text then show XYZ+number, else show nothing (calc fields stays empty).

    Rainer

    1
    Comment actions Permalink
  • Simon Midtgaard Guldberg

    Thank you Rainer!

    0
    Comment actions Permalink
  • Jose Antonio Moyano

    Hi rainer

    I need help you please.

     

    I need to get "1" if I find the string "Box" and "0" if I dont find.

     

    texto var: @All of Cód Tarifa.join ();

    text.indexOf ("Box")> -1? text.substring (text.indexOf ("XYZ"), text.indexOf ("XYZ") + 9): "" (I dont understand this sentence, please help Rainer)

     

    Thanks
    0
    Comment actions Permalink
  • Rainer Grabowski

    Hello Jose Antonio,

    var text = @All of Cód Tarifa.join ();
    text.indexOf ("Box") > -1 ? 1 : 0

    Rainer

    0
    Comment actions Permalink

Please sign in to leave a comment.

Powered by Zendesk