kamsmartx Posted April 25, 2008 Share Posted April 25, 2008 Welcome Question I want to change the value of text field when choosing from a list value of the solution Be interpreted as follows I'm in a field next to the texts and also list and is required when selecting the value of the list and let 1 box sent to neighbouring value figure 1 in the database and let Name Link to comment https://forums.phpfreaks.com/topic/102856-how-to-make-this/ Share on other sites More sharing options...
kamsmartx Posted April 25, 2008 Author Share Posted April 25, 2008 take this code <select name="FileNo" id="select2" onChange="change_title();"> <? $query="SELECT * FROM pationts"; $result=mysql_query($query) or die("error: " . mysql_error()); while($row=mysql_fetch_array($result)) { echo "bla"; ?> <option value="<?php echo $row['FileNo'] ; ?>"><?php echo $row['FileNo'] ; ?></option> <? } ?> </select> the above code is for list i need to select value from it and when i select value we must change vale on the below code <input name="PationtName" type="text" id="title"/> Link to comment https://forums.phpfreaks.com/topic/102856-how-to-make-this/#findComment-526882 Share on other sites More sharing options...
kamsmartx Posted April 25, 2008 Author Share Posted April 25, 2008 Link to comment https://forums.phpfreaks.com/topic/102856-how-to-make-this/#findComment-526899 Share on other sites More sharing options...
zenag Posted April 25, 2008 Share Posted April 25, 2008 i think u have to display corresponding PationtName value should be displayed for selected FileNo am i right???????? Link to comment https://forums.phpfreaks.com/topic/102856-how-to-make-this/#findComment-526901 Share on other sites More sharing options...
kamsmartx Posted April 25, 2008 Author Share Posted April 25, 2008 but how r u see my code Link to comment https://forums.phpfreaks.com/topic/102856-how-to-make-this/#findComment-526905 Share on other sites More sharing options...
zenag Posted April 25, 2008 Share Posted April 25, 2008 <? $con=mysql_connect("localhost","root",""); mysql_select_db("dbname",$con); ?><html> <head> <script type="text/javascript"> function chang() { } var xmlHttp function showCustomer(str) { xmlHttp=GetXmlHttpObject(); if (xmlHttp==null) { alert ("Your browser does not support AJAX!"); return; } var url="chan.php"; url=url+"?id="+str; alert(url); xmlHttp.onreadystatechange=stateChanged; xmlHttp.open("GET",url,true); xmlHttp.send(null); } function stateChanged() { if (xmlHttp.readyState==4) { //alert(xmlHttp.responseText); document.myForm.patname.value=xmlHttp.responseText; } } function GetXmlHttpObject() { var xmlHttp=null; try { // Firefox, Opera 8.0+, Safari xmlHttp=new XMLHttpRequest(); } catch (e) { // Internet Explorer try { xmlHttp=new ActiveXObject("Msxml2.XMLHTTP"); } catch (e) { xmlHttp=new ActiveXObject("Microsoft.XMLHTTP"); } } return xmlHttp; } </script> </head><body> <form name="myForm"> <select onChange="showCustomer(this.value)"name="FileNo" id="select2" onChange="change_title();"> <? $query="SELECT * FROM table"; $result=mysql_query($query) or die("error: " . mysql_error()); while($row=mysql_fetch_array($result)) { ?> <option value="<?php echo $row['field'] ; ?>"><?php echo $row['field'] ; ?></option> <? } ?> <input type="text" name="patname" /> </form> <!--<div id="Hint"></div>--> </select> chan.php <? $con=mysql_connect("localhost","root",""); mysql_select_db("dbname",$con); $id=$_GET["id"]; $sql=mysql_query("select * from table where fieldname='$id'"); while($rows=mysql_fetch_array($sql)) { echo $rows["fieldname"]; } ?> Link to comment https://forums.phpfreaks.com/topic/102856-how-to-make-this/#findComment-526920 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.