Currently my code looks like:

var how_many = "";
        $.ajax({
                type: "POST",
                url: "/ajax_add_selected_product_to_session.php",
                success: function(msg){
                        /* add here what to do on success */
                        //alert(msg);
                        how_many =  msg;
                }
        });

        if($("input[name^='paradigm']:checked").length == 0) {
        //alert('None are checked on page');
                $(".requestbutton").attr("disabled", "disabled");
        }else{
                //alert('At least one is checked');
                $(".requestbutton").removeAttr("disabled");
                $(".requestbutton").click(function(){
                        $("#list").submit();
                });
        }


But I still can't access the var how_many.

I would like to do this: ($("input[name^='paradigm']:checked").length
== 0 || how_many == 0) {

But the how_many is not set... it's empty on alert. Not undefined,
it's empty..

*i am lost...*

On 25 Feb., 11:15, system div <divsys...@gmail.com> wrote:
> you try   alert(check_how_many_products_checked());  //var x = "";
>
> On Wed, Feb 25, 2009 at 6:11 PM, heohni
>
> <heidi.anselstet...@consultingteam.de> wrote:
>
> > Sorry, another question... I just playing arround with different
> > possibilities:
>
> > $(document).ready(function(){
> >        // on default, disable the submit button
> >        $(".requestbutton").attr("disabled", "disabled");
>
> >        function check_how_many_products_checked(){
> >                $.ajax({
> >                        type: "POST",
> >                        url: "/ajax_add_selected_product_to_session.php",
> >                        success: function(msg){
> >                                /* add here what to do on success */
> >                                return msg;
> >                        }
> >                });
> >        }
>
> >        var x = "";
> >        x = check_how_many_products_checked();
> >        alert(x);
>
> > The alert is always "undefined"...
> > Why? I must return the figure 2, what it does, if I alert the msg
> > directly.
> > Sorry for these questions, I am just about to learn the syntax.
> > Thanks!
>
> > On 25 Feb., 10:57, heohni <heidi.anselstet...@consultingteam.de>
> > wrote:
> >> Ok, thanks a lot!!
>
> >> On 25 Feb., 10:38, system div <divsys...@gmail.com> wrote:
>
> >> >  var how_many_checked= '';
>
> >> > $.ajax({
> >> >                type: "POST",
> >> >                url: "/ajax_add_selected_product_to_session.php",
> >> >                success: function(msg){
> >> >                        /* add here what to do on success */
> >> >                        //alert(msg);
> >> >                       how_many_checked = msg;
>
> >> >                }
> >> >        });
> >> > alert(how_many_checked);
> >> > if(how_many_checked !=undefined) {
> >> > do some..................................................
>
> >> > }
>
> >> > On Wed, Feb 25, 2009 at 5:31 PM, heohni
>
> >> > <heidi.anselstet...@consultingteam.de> wrote:
>
> >> > > Hi,
>
> >> > > $.ajax({
> >> > >                type: "POST",
> >> > >                url: "/ajax_add_selected_product_to_session.php",
> >> > >                success: function(msg){
> >> > >                        /* add here what to do on success */
> >> > >                        //alert(msg);
> >> > >                        var how_many_checked = msg;
>
> >> > >                }
> >> > >        });
> >> > > alert(how_many_checked);
> >> > > if(how_many_checked > 0) .......
>
> >> > > the FF returns "how_many_checked" ist not defined.
> >> > > Why?
>
> >> > > How can I define a var and use it for a later coming if / else part?
>
> >> > > Thanks a bunch!

Reply via email to