NathanS Posted November 16, 2007 Share Posted November 16, 2007 Hi guys, I've just created an ajax form whereby if you select one option from a dropdown list, it'll populate the next one dependent on the choice. However, I have used an array for this so far, but I need to read from a MySQL database - anyone give any clues as to the best way of doing this? I've included my code below. Thanks in advance!! Array (dataPage.php) <?php $dataOptions = array(); $dataOptions["Ford"] = array("Choose One", "Fiesta", "Focus", "Escort", "KA"); $dataOptions["Renault"] = array("Choose One", "Scenic", "Clio", "Espace", "Megane"); $dataOptions["Fiesta"] = array("Choose One", "GTI", "Blah", "BlahExec"); if(isset($_POST["dataRequest"]) && isset($dataOptions[$_POST["dataRequest"]])) { foreach($dataOptions[$_POST["dataRequest"]] as $secondaryOptions) { printf("%s,", $secondaryOptions); }} ?> dynamicForm AJAX function clearField(obj) { if (obj.defaultValue==obj.value) obj.value = ''; } function chooseVehicle(requestedData,objectID) { fetchData('dataPage.php',requestedData,objectID); } function filterData(pageRequest,objectID){ if (pageRequest.readyState == 4 && (pageRequest.status==200 || window.location.href.indexOf("http")==-1)) { var object = document.getElementById(objectID); object.options.length = 0; if(pageRequest.responseText != '') { var arrSecondaryData = pageRequest.responseText.split(','); for(i = 0; i < arrSecondaryData.length; i++) { if(arrSecondaryData[i] != '') object.options[object.options.length] = new Option(arrSecondaryData[i], arrSecondaryData[i]); }}}} Quote Link to comment Share on other sites More sharing options...
rajivgonsalves Posted November 16, 2007 Share Posted November 16, 2007 read from the mysql database or write it too a mysql database ? if its read what is your database fieldname etc. more information is required Quote Link to comment Share on other sites More sharing options...
NathanS Posted November 16, 2007 Author Share Posted November 16, 2007 Read from, instead of reading from the array I need it to read from a table called system_list_vehicle. The database fields are: ABIMAKE, ABIMODEL, ABIMARK Thanks! Quote Link to comment Share on other sites More sharing options...
NathanS Posted November 16, 2007 Author Share Posted November 16, 2007 It also has 40,000 rows. ??? Quote Link to comment Share on other sites More sharing options...
rajivgonsalves Posted November 16, 2007 Share Posted November 16, 2007 40,000 rows getting it into anything into html will hang your browser choose some criteria you wanna select them on otherwise your just gonna hang the browser 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.