i have popup form, used select items in table. in order, table data each row is: (checkbox selection), schema name, , table name.
here query used data listing:
select table_schema, table_name information_schema.tables order table_schema, table_name
how creating table listing:
<?php $db = new mssql($_session['serv'],$_post['database'],$_session['usr_n'],$_session['pa ss']); $db->query(" select table_name, table_schema information_schema.tables order table_schema, table_name "); $tables = $db->getarray(); foreach($tables $table) { print "<tr>"; print "<td><input type='checkbox' name='$table[table_name]' class='checkbox' /></td>"; //print checkbox print "<td style='padding: 5px; text-align: center;'>$table[table_schema]</td>"; //print table schema print "<td>$table[table_name]</td>"; //print table name print "<td><input type='hidden' name='$table[table_name]_schema' value='$table[table_schema]'></td>"; print "</tr>"; } ?>
i trying add filter. want place drop down list of of distinct schemas returned query above. i've done using following:
<option value="%" selected>all schemas</option> <?php $db = new mssql($_session['serv'], $_post['database'], $_session['usr_n'],$_session['pass']); $db->query(" select distinct table_schema information_schema.tables order table_schema "); $schemas = $db->getarray(); foreach($schemas $schema) { ?> <option value="<?php echo $schema['table_schema'];?>"><?php echo $schema['table_schema']?></option> <?php } ?>
this working correctly, , when access drop down in javascript, getting correct value when displaying alert.
what need happen when user selects different schema list (onchange) table update, displaying tables specified schema. i've been trying use limited knowledge of javascript , php figure out, after searching several questions related, i've come understanding need use ajax. know little it, , not finding tutorials online helpful.
so stuck on sending value of drop down php file, array back, , return javascript. i'll remove rows display table, , add in new values array passed in.
here i've got far:
function updatelist() { var sch = document.getelementbyid("schlist"); var xmlhttp; if(window.xmlhttprequest) { xmlhttp=new xmlhttprequest(); } else { xmlhttp=new activexobject("microsoft.xmlhttp"); } xmlhttp.onreadystatechange=function() { if(xmlhttp.readystate==4 && xmlhttp.status==200) { var table = xmlhttp.response } } }
from here have no clue. i've read called json, , can return objects , arrays. how send schema name on file, , how return array file?
thanks help!
if not knowledgeable in subject don't attempt via ajax. reload page url var tells page load ie. table.php?id=users
once working without ajax can add feature in if necessary.
if wondering js reload see : http://webdesign.about.com/od/examples/l/blfaqddredirect.htm
Comments
Post a Comment