// THIS JAVASCRIPT FUNCTION IS USED TO CREATE DYNAMIC COMBOS USING AJAX // /** * Sweadi * AJAX Combo Updater * * LICENSE: The source file is subject to GNU Public License * You can Modify, Delete, Use this Class in Personal and Commerical Projects * * * @author Asad Mehmood * @copyright 2009 sweadi * @version v1.0.1 02/13/2009 16:18:46 PM */ /** * Create a Dynamic Drop Down List by Changing the value of One * * @param table name of the table from which the values are to be selected * @param value the field name that will be option value * @param label the field name that will be label for the option * @param con_field The name of field which will be used in where clause for filtering records * @param con_value The value of the condition field * @param sel_field Option Value that needs to be selected * @param order Which Order the list needs to be created if empty will be ASCENDING */ var select_id; var selected_val=""; function check(table, value, label, con_field, con_value, sel_id, order, selected ) { select_id = sel_id; selected_val = selected; if (window.XMLHttpRequest) { http_request = new XMLHttpRequest(); } else if (window.ActiveXObject) { http_request = new ActiveXObject("Microsoft.XMLHTTP"); } url ='http://autocraftchile.com/secure/ajax/combo.ajax.php?action=comboxml&table='+table+'&value='+value+'&label='+label+'&con_field='+con_field+'&con_value='+con_value+'&order='+order; //window.open(url); try { http_request.open('GET', url,true) } catch(err){alert(err.toString());} http_request.onreadystatechange = handleResponseCombo; try { http_request.send(null); }catch(err){alert(err.toString());} } function handleResponseCombo() { if(http_request.readyState != 4) { document.getElementById('loadingDiv').innerHTML = ''; } if (http_request.readyState == 4) { xmlDoc=http_request.responseXML; var newOpt = new Option("Select","", false); document.getElementById(select_id).length = 0; document.getElementById(select_id).options[0] = newOpt; for( i=0; i