facebook

Assign a dynamic variable to a field name?

💡
Our Forums Have Moved

For help with installation, bugs reports or feature requests, please head over to our new forums.
Genuitec Community on GitHub

  1. MobiOne Archive
  2.  > 
  3. Getting Help – General
Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #343568 Reply

    Robert Gardner
    Participant

    Is is possible to assign a dynamic variable to a field name?

    Consider that I have several field names in my app QQ_Leg1_To, QQ_Leg2_To etc..

    $('#m1-QuickQuote-QQ_Leg1_To').val()

    Is it possible to code this as

    $('#m1-QuickQuote-QQ_Leg[b]&Num[/b]_To').val()

    where I pass a value (2 for example) to &Num and the widget is recognized as

    $('#m1-QuickQuote-QQ_Leg2_To').val()

    in my function?

    If not could someone suggest an approach that would accomplish the same thing?

    Hope I made my objective clear… If not please ask..

    Thank you,

    #343569

    Robert Gardner
    Participant

    apologies… the [b] stuff was supposed to bold the dynamic variable I used in my example. it should simply be &Num

    #343588

    Hi aviator21114,

    It is not very clear where do you get the var num, but this should help you to getting started. Change the value of num var for the value of a textfield, combobox or any other widget you are using.

    
    var num = 5;
    var select = '#m1-QuickQuote-QQ_Leg' + num + '_To';
    $(select).val()
    

    Hope this make sense, let me know how it goes.

    #343590

    Robert Gardner
    Participant

    Octavio,

    That construct makes perfect sense and helps immensely.. I will test this and implement..

    Thank you,

Viewing 4 posts - 1 through 4 (of 4 total)
Reply To: Assign a dynamic variable to a field name?

You must be logged in to post in the forum log in