1. #1
    Sencha User
    Join Date
    Apr 2012
    Posts
    24
    Vote Rating
    0
    developerankit is on a distinguished road

      0  

    Default having problem with arrays

    having problem with arrays


    Hello All,

    I am having some problem with arrays, actually I have three text fields with same name like 'golfers[]' (array type). Now I need to validate that at least one of them should be entered or non-empty. Please help me how I can validate it. I am using form.submit method to post the form.

    Please help me ASAP....

    Thanks
    Ankit Aggarwal

  2. #2
    Sencha - Community Support Team sword-it's Avatar
    Join Date
    May 2012
    Location
    Istanbul
    Posts
    1,333
    Vote Rating
    85
    sword-it is a jewel in the rough sword-it is a jewel in the rough sword-it is a jewel in the rough sword-it is a jewel in the rough

      0  

    Default TRY THIS

    TRY THIS


    Hi Ankit,

    Try this code in your save function:-

    Code:
    , save: function () {
            var fields = YourForm.find('name', 'golfers')
               , count = 0;
            for (var i = 0; i < fields.length; i++) {
                if (fields[i].getValue() != '') {
                    count++;
                }
            }
            if (count != 0) {
                //your form posting come here
            }
        }
    sword-it.com, Sencha Developer House in Turkey - Istanbul University Technopark Suite 204.

  3. #3
    Sencha User
    Join Date
    Apr 2012
    Posts
    24
    Vote Rating
    0
    developerankit is on a distinguished road

      0  

    Default Not working

    Not working


    Hi Sword

    Thanks for reply, but its not working. I think form panel has no method name 'find' and I am getting the same error as well...

    Thanks
    Ankit

  4. #4
    Sencha - Community Support Team sword-it's Avatar
    Join Date
    May 2012
    Location
    Istanbul
    Posts
    1,333
    Vote Rating
    85
    sword-it is a jewel in the rough sword-it is a jewel in the rough sword-it is a jewel in the rough sword-it is a jewel in the rough

      0  

    Default


    Hi,

    I guess, you are not getting anything in form (form.find(...)
    Provide me your code
    sword-it.com, Sencha Developer House in Turkey - Istanbul University Technopark Suite 204.

  5. #5
    Sencha User
    Join Date
    Apr 2012
    Posts
    24
    Vote Rating
    0
    developerankit is on a distinguished road

      0  

    Default my code

    my code


    Hi Sword

    Please find my code below

    var fields = this.getGolferForm().find('name', 'golfers');
    var count = 0;
    for (var i = 0; i < fields.length; i++) {
    if (fields[i].getValue() != '') {
    count++;
    }
    }
    if (count != 0) {
    this.getGolferForm().submit({
    url: 'services/index.php/play/gameGolfers',
    method: 'POST',
    params: {email: sessionStorage.getItem("email"), game_id: 101},
    success: function(result, response) {
    if(response.msg == 'SUCCESS') {
    Ext.Msg.alert('Your golfer saved successfully');
    }
    },
    failure: function(result, response) {
    Ext.Msg.alert(response);
    },
    });
    }

    Thanks
    Ankit

  6. #6
    Sencha - Community Support Team sword-it's Avatar
    Join Date
    May 2012
    Location
    Istanbul
    Posts
    1,333
    Vote Rating
    85
    sword-it is a jewel in the rough sword-it is a jewel in the rough sword-it is a jewel in the rough sword-it is a jewel in the rough

      0  

    Default


    Hi,

    May i know what you are getting from this.getGolferForm()??

    Debug your code and check what you are getting from it...

    sword-it.com, Sencha Developer House in Turkey - Istanbul University Technopark Suite 204.

  7. #7
    Sencha User
    Join Date
    Apr 2012
    Posts
    24
    Vote Rating
    0
    developerankit is on a distinguished road

      0  

    Default


    Hi

    its returns and alert as [object Object], if you are not getting me properly, you can come to skype: 'developerankit'.

    Thanks
    Ankit

  8. #8
    Sencha - Community Support Team sword-it's Avatar
    Join Date
    May 2012
    Location
    Istanbul
    Posts
    1,333
    Vote Rating
    85
    sword-it is a jewel in the rough sword-it is a jewel in the rough sword-it is a jewel in the rough sword-it is a jewel in the rough

      0  

    Default


    Try one of the following:-
    • this.getGolferForm().findField('golfers')
    • form.items.filter('name', 'golfers') would work like find method
    • call getValues and split the data like var values = form.getValues().golfers.split(',') and loop in the comma separated values.



    sword-it.com, Sencha Developer House in Turkey - Istanbul University Technopark Suite 204.

  9. #9
    Sencha User
    Join Date
    Apr 2012
    Posts
    24
    Vote Rating
    0
    developerankit is on a distinguished road

      0  

    Default Not working

    Not working


    Hi

    nothing worked...

    Thanks
    Ankit

  10. #10
    Sencha User
    Join Date
    Dec 2011
    Posts
    20
    Vote Rating
    0
    narram123 is on a distinguished road

      0  

    Default Try this

    Try this


    Hi Ankit,

    Put a console.log() and check what you are getting from this.getGolferForm().


    Thanks,
    Narram

Thread Participants: 2

Tags for this Thread

Turkiyenin en sevilen filmlerinin yer aldigi xnxx internet sitemiz olan ve porn sex tarzi bir site olan mobil porno izle sitemiz gercekten dillere destan bir durumda herkesin sevdigi bir site olarak tarihe gececege benziyor. Sitenin en belirgin ozelliklerinden birisi de Turkiyede gercekten kaliteli ve muntazam, duzenli porno izle siteleri olmamasidir. Bu yuzden iste. Ayrica en net goruntu kalitesine sahip adresinde yayinlanmaktadir. Mesela diğer sitelerimizden bahsedecek olursak, en iyi hd porno video arşivine sahip bir siteyiz. "The Best anal porn videos and slut anus, big asses movies set..." hd porno faketaxi