rameshfaj Posted February 23, 2007 Share Posted February 23, 2007 I need to have two selection fields whose value are populated from the database. When the user selects a particular value in field A then the user should only be able to select the values in the second list that change with the value of the first list. Ex: List A,if has values like number,characters,operators, then if the user selects the value number then the field B should contain values 0,1,-9, when the value of the first field is character, the second field should be populated with the values like A,B---, similarly for the operator values in the first field,the option values in the second field should be +,_,-,*,% etc. How can I achieve this?Plz help me. Quote Link to comment Share on other sites More sharing options...
suma237 Posted February 27, 2007 Share Posted February 27, 2007 hi, list means-dropdown menu or some thing else. i will send u a sample code. index.php if name of the client is selected then corresponding mail id should displayed.... <tr> <td >ClientName</td> <td ><? $sql_sel="select * from tb_client"; $db->query($sql_sel)or die($db->error()); echo "<select name='client_id' onChange='info1()'>"; /*echo "<option>Select Client Name</option>";*/ while($row5=$db->fetchArray()) echo "<option value=\"$row5[mailid]\">$row5[clientname]</option>"; echo "</select>"; ?></td> </tr> <tr> <td >ClientMail ID</td> <td > <!--<input name="email3" id="my_div" size="30">--> <div id="my_div"> Select Client Name: </div> </td> </tr> Script.js---this page contain ajax coding // JavaScript Document //Create Microsoft.XMLHTTP Object function makeObject(){ var x; var browser = navigator.appName; //detect the client browser if(browser == "Microsoft Internet Explorer"){ x = new ActiveXObject("Microsoft.XMLHTTP"); }else{ x = new XMLHttpRequest(); } return x; } //call the function makeObject() var request = makeObject(); //function send request function info1(){ //alert("hh"); var val = document.form.client_id.options[document.form.client_id.selectedIndex].value; //alert(val); request.open('get', 'test.php?id=' + val); request.onreadystatechange = parseInfo; request.send(''); } //function send data function parseInfo(){ if(request.readyState == 1){ document.getElementById('my_div').innerHTML = 'Loading...'; } if(request.readyState == 4){ var answer = request.responseText; document.getElementById('my_div').innerHTML = answer; } } test.php--the value is displayed in the div area of index.php <?if( $_GET['id'] != "" ) { //echo "hhh"; echo $id=$_GET['id']; } ?> Quote Link to comment Share on other sites More sharing options...
muzammil Posted May 11, 2007 Share Posted May 11, 2007 i have same problem i try to use javascript but it refreshing the page, i have 3 table (country, state, city) i want to display only respective state shown when a country is selected. and same for state and city). i am using php mysql hope to get reply soon 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.