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/102855-how-to-make-this/ Share on other sites More sharing options...
Goose Posted April 25, 2008 Share Posted April 25, 2008 kamsmartx I don't quite follow what you are asking here. If you have a JavaScript object, lets cal it obj. // this changes the value of the object obj.value = 'a new value'; You can also but the above code into some sort of function and add an event listener to your list. Something like this: <input id="list" onchange="yourFunction();" /> Hopefully this helps, if not, please try and re-ask your question. Or maybe someone else gets it Link to comment https://forums.phpfreaks.com/topic/102855-how-to-make-this/#findComment-526874 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/102855-how-to-make-this/#findComment-526881 Share on other sites More sharing options...
Goose Posted April 25, 2008 Share Posted April 25, 2008 So in the change_title() function you want to say something like document.getElementById('title').value = document.getElementById('select2').value; Link to comment https://forums.phpfreaks.com/topic/102855-how-to-make-this/#findComment-526884 Share on other sites More sharing options...
kamsmartx Posted April 25, 2008 Author Share Posted April 25, 2008 no your code print Number of Pationt but i need when i select Number of Pationt the change on next text filed print name of pationt Link to comment https://forums.phpfreaks.com/topic/102855-how-to-make-this/#findComment-526886 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/102855-how-to-make-this/#findComment-526888 Share on other sites More sharing options...
kamsmartx Posted April 25, 2008 Author Share Posted April 25, 2008 i think put pationname with list am i Link to comment https://forums.phpfreaks.com/topic/102855-how-to-make-this/#findComment-526906 Share on other sites More sharing options...
kamsmartx Posted April 25, 2008 Author 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/102855-how-to-make-this/#findComment-526910 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/102855-how-to-make-this/#findComment-526919 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.