开发者

Javascript passing variable from function to function

开发者 https://www.devze.com 2023-02-17 20:52 出处:网络
How do i pass var rating and var itervalue into my window.location.replace? i get new rating variable from function updateRating() and when i click hireraccept, it assigns a new itervalue variable whi

How do i pass var rating and var itervalue into my window.location.replace? i get new rating variable from function updateRating() and when i click hireraccept, it assigns a new itervalue variable which i wish to pass them both into the "proceed" button into the window.location.replace url. any idea?

   <script type="text/javascript">
   $(document).ready(function(){
   var rating =  0;
   var itervalue = 0;

   $(".hireraccept").click(function(){
                $('.jRating').jRating();
                $("#dialog-rate").dialog("open");
                var itervalue = $(this).attr("value");


                return false

            });


            $("#dialog-rate").dialog({

                autoOpen: false,
                resizable: false,
                height: 200,
                width: 200,        
                modal: true,
        开发者_如何学JAVA        buttons: {
                    "Proceed": function(){

                        window.location.replace("{{ domain_url }}/workroom/accept/" + itervalue +"/" + rating);
                        $(this).dialog("close");

                    }

                }


            });

  });
 </script>
     <script type="text/javascript"> 
      function updateRating(rate,proceed){
      goodtogo = proceed;

      rating = rate;

} 
    </script>


You have your iterval declared globally, but then redeclare it locally. Remove the var declaration from your click handler and it will overwrite the global value, which you can then use in your dialog opening options.

// edit Change this

var itervalue = $(this).attr("value");

to this, and that should work

itervalue = $(this).attr("value");
0

精彩评论

暂无评论...
验证码 换一张
取 消