I have these 3 script where one I collect values by means of ajax from another but I want to send the value collected from the other script generated by ajax.
this is the index
<html>
<head>
<script src="http://code.jquery.com/jquery-1.9.1.js"></script>
<script src="https://code.jquery.com/jquery-3.2.1.min.js"></script>
<script language="javascript">
$(document).ready(function(){
$("#nombre").change(function () {
$("#nombre option:selected").each(function () {
elegido=$(this).val();
$.post("modelos.php", { elegido: elegido }, function(data){
$("#telefono").html(data);
});
});
})
});
</script>
</head>
<body>
<form action="combo2.php" method="post">
<p>Marca:
<select name="nombre" id="nombre">
<?php
$con = mysql_connect('localhost','root', 'master3.1416');
mysql_select_db('tel', $con);
$sql = mysql_query("SELECT * FROM tel ORDER BY nombre " ,$con);
$contar = @mysql_num_rows($sql);
if($contar == 0){
}else{
while($row=mysql_fetch_array($sql)){
$id = $row['id'];
?>
<option value='<?php echo $nombre = $row["nombre"]; ?>'> <?php echo $nombre = $row["nombre"]; ?> </option>
<?php
}
}
?>
</select> </p>
<p>Modelo:
<select name="telefono" id="telefono">
<option value='<?php echo $tel = $row["tel"]; ?>' name='tel' id='tel'> </option>
</select></p>
<input name='submit' type='submit' value='Guardar' />
</form>
</body>
</html>
The above script picks up the value from this script below.
<?php
$elegido = $_POST['elegido'];
$con = mysql_connect('localhost','root', 'master3.1416');
mysql_select_db('tel', $con);
$sql = mysql_query("SELECT * FROM tel WHERE nombre = '$elegido'" ,$con);
$contar = @mysql_num_rows($sql);
if($contar == 0){
}else{
while($row=mysql_fetch_array($sql)){
$tel = $row['tel'];
echo '<option value="'.$row['tel'].'" id="tel" name="tel">'.$row['tel'].'</option>';
}
}
?>
But the value I want to send here, but only send me the name:
<?php
$nombre = $_POST['nombre'];
$tel = $_POST['tel'];
echo" $nombre";
echo" $tel";
?>