jquery - javascript returning an array from inside a get funtion with in a function -
new javascript , jquery have bee doing of coding in php, have been banging head against wall week trying work, have looked through out site , googled many others issues!
here complete function think pretty self explanatory
function get_all_items(config_d) { var con = config_d.split(','); var cat = $("#category").val(); var color = $("#c"+cat+"").val(); var range = $("#range").val(); var total = $("#vtotal").val(); var prod_arr = ""; var qty_arr = ""; $.get('tables/htl_products.txt', function(data) { var lines = data.split('\n'); (var i=0; i<=lines.length; i++) { var elements = lines[i].split('~'); var el = elements[0].split('_'); var arange = el[0]; var aproduct = elements[0]; var aconfig = elements[1]; var acat = elements[2]; var acolor = elements[3]; (var c=0; c<con.length; c++) { var config22 = con[c]; var config1 = config22.replace("x", "v"); var vchk = $('#'+range+config1+'').is(':checked'); if (vchk==true) { var config23 = config1; var config2 = config23.replace("v", "x"); var q_id = "#q_"+arange+"_"+config2+""; var qty = $(""+q_id+"").val(); if (qty=="") { qty=0; } var qq = parseint(""+qty+""); } else { var config23 = config22; var q_id = "#q_"+arange+"_"+config22+""; var qty = $(""+q_id+"").val(); if (qty=="") { qty=0; } var qq = parseint(""+qty+""); } if (range==arange && config23==aconfig && cat==acat && qq > 0 && color==acolor ) { // these 2 strings wish use outside of function!!! var prod_arr = prod_arr+','+aproduct; var qty_arr = qty_arr+','+qq; } } } }); // @ moment trying display variables // wish use variables here alert(""+prod_arr+"~"+qty_arr+""); // plan here pass variables , open php page // window.open("test.php?total="+total+"&aa="+prod_arr+"&qq="+qty_arr+"","_self"); }
i know may bit clunky seems work except use of variables @ end of parent function??
thanks in advance assistance
Comments
Post a Comment