june_c21 Posted March 15, 2008 Share Posted March 15, 2008 hi, i got problem when i click on the option value in 1st drop down, the 2nd drop down menu didn't appear. Anything wrong in my php code ? html code <html> <head> <title>My Page</title> <script type="text/javascript"> // SharpAJAX initialization // Create AJAX object based on browser if (navigator.appName == "Microsoft Internet Explorer") { sharpajax = new ActiveXObject("Microsoft.XMLHTTP"); } else { sharpajax = new XMLHttpRequest(); } // Initialize sharpajax.abort(); </script> <script type="text/javascript"> // My Function function filter(value) { // Resets state sharpajax.abort(); // Send command sharpajax.open("GET","filter.php?filter="+value); // Create input trapping function sharpajax.onreadystatechange=function() { if (sharpajax.readyState == 4) { eval(sharpajax.responseText); } } // Send output sharpajax.send(""); } </script> <script type="text/javascript"> function createDropdown(container, id) { document.getElementById(container).innerHTML = ''+ '<select name="'+id+'" id="'+id+'">'+ '</select>'; } function addDropdownItem(container, value, caption) { document.getElementById(container).innerHTML = ''+ document.getElementById(container).innerHTML + '<option value="'+value+'">'+caption+'</option>'; } </script> </head> <body> <div id="filters_1"> <select name="filter1" id="filter1" onChange="javascript:filter(this.value);"> <option value="name">Name</option> <option value="birthdate">Birthdate</option> </select> </div> <div id="filters_2"></div> </body> </html> php code <?php $myfilter = $_GET['filter']; // SQL query statements goes here $host = 'localhost'; $user = 'root'; $password = ''; $dbase = 'drawing'; $dblink = mysql_connect($host,$user,$password); mysql_select_db($dbase,$dblink); $filters_2 = $_POST['title']; $query = "SELECT title FROM drawings "; $result1 = mysql_query($query, $dblink); while($myrow1 = mysql_fetch_row($result1)) { printf("createDropdown('filters_2','filter_2');"); printf("addDropdownItem('filter_2','filtervalue',' filtercaption'"); } ?> Quote Link to comment Share on other sites More sharing options...
june_c21 Posted March 15, 2008 Author Share Posted March 15, 2008 please help... Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.