<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[How to change two input fields with one onchange event]]></title><description><![CDATA[<p dir="auto">i want to change two inputs according to the selected value form another field<br />
i have try this code and it gives two value that i want but it not showing on two different filed. its only showing two values in one field as two selections<br />
<em><strong>This is my code</strong></em></p>
<p dir="auto"><strong>book-appointment .php</strong></p>
<pre><code>&lt;script&gt;
function getdoctor(val) {
	$.ajax({
	type: "POST",
	url: "../get_doctor.php",
	data:'specilizationid='+val,
	success: function(data){
		$("#doctor").html(data);
	}
	});
}
&lt;/script&gt;	

&lt;script&gt;
function getAppNumber(val) {
	$.ajax({
	type: "POST",
	url: "../get_doctor.php",
	data:'doctor='+val,
	success: function(data){
		$("#AppNumber").html(data);
	}
	});
}
&lt;/script&gt;	


&lt;script&gt;
function getfee(val) {
	$.ajax({
	type: "POST",
	url: "../get_doctor.php",
	data:'doctor='+val,
	success: function(data){
		$("#fees").html(data);
	}
	});
}
&lt;/script&gt;

&lt;div class="form-group"&gt;
	&lt;label for="DoctorSpecialization"&gt;
		Doctor Specialization
	&lt;/label&gt;
	&lt;select name="Doctorspecialization" class="form-control" onChange="getdoctor(this.value);" required="required"&gt;
		&lt;option value=""&gt;Select Specialization&lt;/option&gt;
		&lt;?php 
			$ret=mysqli_query($con,"select * from doctorspecilization");
		        while($row=mysqli_fetch_array($ret))
			{
			?&gt;
		&lt;option value="&lt;?php echo htmlentities($row['specilization']);?&gt;"&gt;
		&lt;?php echo htmlentities($row['specilization']);?&gt;
		&lt;/option&gt;
		&lt;?php } ?&gt;
							
	&lt;/select&gt;
&lt;/div&gt;



&lt;div class="form-group"&gt;
        &lt;label for="doctor"&gt;
	     Doctor
	&lt;/label&gt;
	&lt;select name="doctor" class="form-control" id="doctor" onChange="getfee(this.value);getAppnumber(this.value);" required="required"&gt;
	       &lt;option value=""&gt;Select Doctor&lt;/option&gt;
	&lt;/select&gt;
&lt;/div&gt;
	&lt;div class="form-group"&gt;
		&lt;label for="consultancyfees"&gt;
		         Consultancy Fees
		&lt;/label&gt;
	&lt;select name="fees" class="form-control" id="fees"  readonly&gt;

	&lt;/select&gt;
&lt;/div&gt;
&lt;div class="form-group"&gt;
	&lt;label for="appinmentnumber"&gt;
		Appoinment Number
	&lt;/label&gt;
	&lt;select name="AppNumber" class="form-control" id="AppNumber"  readonly&gt;
	&lt;/select&gt;
&lt;/div&gt;
</code></pre>
<p dir="auto"><strong>get_doctor.php</strong></p>
<pre><code>&lt;?php
include('include/config.php');
if(!empty($_POST["specilizationid"])) 
{

 $sql=mysqli_query($con,"select doctorName,id from doctors where specilization='".$_POST['specilizationid']."'");?&gt;
 &lt;option selected="selected"&gt;Select Doctor &lt;/option&gt;
 &lt;?php
 while($row=mysqli_fetch_array($sql))
 	{?&gt;
  &lt;option value="&lt;?php echo htmlentities($row['id']); ?&gt;"&gt;&lt;?php echo htmlentities($row['doctorName']); ?&gt;&lt;/option&gt;
  &lt;?php
}
}


if(!empty($_POST["doctor"])) 
{

 $sql=mysqli_query($con,"select docFees from doctors where id='".$_POST['doctor']."'");
 while($row=mysqli_fetch_array($sql))
 	{?&gt;
 &lt;option value="&lt;?php echo htmlentities($row['docFees']); ?&gt;"&gt;&lt;?php echo htmlentities($row['docFees']); ?&gt;&lt;/option&gt;
  &lt;?php
}
}

if(!empty($_POST["doctor"])) 
{

 $sql=mysqli_query($con,"select doctorId,COUNT(AppNumber)+1 as nextAppNumber from appointment  where doctorId='".$_POST['doctor']."' group by doctorId order by doctorId DESC");
 while($row=mysqli_fetch_array($sql))
 	{?&gt;
 &lt;option value="&lt;?php echo htmlentities($row['nextAppNumber']); ?&gt;"&gt;&lt;?php echo htmlentities($row['nextAppNumber']); ?&gt;&lt;/option&gt;
  &lt;?php
}
}

?&gt;


</code></pre>
<p dir="auto">Thank you for help</p>
]]></description><link>https://lankadevelopers.lk/topic/407/how-to-change-two-input-fields-with-one-onchange-event</link><generator>RSS for Node</generator><lastBuildDate>Mon, 18 May 2026 02:38:17 GMT</lastBuildDate><atom:link href="https://lankadevelopers.lk/topic/407.rss" rel="self" type="application/rss+xml"/><pubDate>Thu, 10 Oct 2019 09:05:28 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to How to change two input fields with one onchange event on Sun, 03 Nov 2019 15:00:28 GMT]]></title><description><![CDATA[<p dir="auto">you can write all your javascripts in on tag.</p>
<p dir="auto">&lt;script&gt;<br />
function getdoctor(val) {<br />
$.ajax({<br />
type: "POST",<br />
url: "../get_doctor.php",<br />
data:'specilizationid='+val,<br />
success: function(data){<br />
// i assume that your data on ajaxs success has 2 properties in the object<br />
$("#input1").val(data.item1);<br />
$("#input2").val(data.item1);<br />
}<br />
});<br />
}<br />
&lt;/script&gt;</p>
]]></description><link>https://lankadevelopers.lk/post/2455</link><guid isPermaLink="true">https://lankadevelopers.lk/post/2455</guid><dc:creator><![CDATA[tnlthanzeel]]></dc:creator><pubDate>Sun, 03 Nov 2019 15:00:28 GMT</pubDate></item></channel></rss>