of illustrations.
-
How do I take a name and its output appears in a textbox?
-
and at the same time it appears appropriate selectbox2 id of selectbox1.
-
The case number 2 is already finished a case number one yet.
here’s code javascript of index.php
$(document).ready(function()
{
$(".country").change(function()
{
var id=$(this).val();
var dataString = 'id='+ id;
$.ajax
({
type: "POST",
url: "get_state.php",
data: dataString,
cache: false,
success: function(html)
{
$(".state").html(html);
}
});
});
$(".country").change(function()
{
var id=$(this).val();
var dataString = 'id='+ id;
$.ajax
({
type: "POST",
url: "get_name.php",
data: dataString,
cache: false,
success: function(html)
{
$(".country_name").val=html;
}
});
});
});
here’s code form in index.php:
<select name="country" class="country">
<option selected="selected">--Select Country--</option>
<?php
$stmt = $DB_con->prepare("SELECT * FROM tbl_country");
$stmt->execute();
while($row=$stmt->fetch(PDO::FETCH_ASSOC))
{
?>
<option value="<?php echo $row['country_id']; ?>"><?php echo $row['country_name']; ?></option>
<?php
}
?>
</select>
<label>Nama Negara</label>
<input type="text" name="country_name" class="country_name">
<label>State :</label> <select name="state" class="state">
<option selected="selected">--Select State--</option>
</select>
here’s code of get_name.php
<?php
include('dbconfig.php');
if($_POST['id'])
{
$id=$_POST['id'];
$stmt = $DB_con->prepare("SELECT country_name FROM tbl_country WHERE country_id=:id");
$stmt->execute(array(':id' => $id));
while($row=$stmt->fetch(PDO::FETCH_ASSOC))
{
echo $row['country_name'];
}
}
?>
Please help me, thank you.