Good morning,
I have this form where in the comboboxes the desired values already appear: [1] [1]
Now I have a problem, because when I select the product, I want the unit of the product to automatically appear on the label "Unit."
This is the code I used to populate the "Product" combobox:
<form name="Registo" action="conexao.php" method="POST">
<b>Produtos:</b>
<br>
<select name="select_Produtos">
<option>Selecione</option>
<?php
$result_Produtos = "SELECT * FROM Produtos";
$resultado_Produtos = mysqli_query($conn, $result_Produtos);
while($row_Produtos = mysqli_fetch_assoc($resultado_Produtos)){ ?>
<option value="<?php echo $row_Produtos['ID']; ?>"><?php echo $row_Produtos['Product']; ?>
</option> <?php
}
?>
</select><br>
And now it's the code for the rest of the form:
<b>Unidade:</b>
<br>
<input type="text" name="TipoUnid" size="20"><br>
<b>Quantidade:</b>
<br>
<input type="text" name="Amount" size="5"><br>
<b>Observações (Opcional):</b>
<br>
<textarea name="Comments" cols="30" rows="5"> </textarea><br>
<b>Quarto (Opcional):</b>
<br>
<select name="select_Bedroom">
<option>Selecione</option>
<?php
$result_Quarto = "SELECT * FROM Quarto";
$resultado_Quarto = mysqli_query($conn, $result_Quarto);
while($row_Quarto = mysqli_fetch_assoc($resultado_Quarto)){ ?>
<option value="<?php echo $row_Quarto['ID']; ?>"><?php echo $row_Quarto['Bedroom']; ?>
</option> <?php
}
?>
</select><br>
<br>
<input type="submit" name="adicionar" value="Adicionar">
</form>
Can someone help me?
CREATE TABLE 'Estado' (
'ID' int(11) NOT NULL AUTO_INCREMENT,
'IDProd' int(11) NOT NULL,
'Active' tinyint(1) NOT NULL,
PRIMARY KEY ('ID')
) ENGINE=InnoDB AUTO_INCREMENT=41 DEFAULT CHARSET=latin1;
CREATE TABLE 'Quarto' (
'ID' int(11) NOT NULL AUTO_INCREMENT,
'Bedroom' int(11) NOT NULL,
PRIMARY KEY ('ID')
) ENGINE=InnoDB AUTO_INCREMENT=41 DEFAULT CHARSET=latin1;
CREATE TABLE 'Unidades' (
'ID' int(11) NOT NULL AUTO_INCREMENT,
'Description' varchar(30) NOT NULL,
PRIMARY KEY ('ID')
) ENGINE=InnoDB AUTO_INCREMENT=8 DEFAULT CHARSET=latin1;
CREATE TABLE 'Registo' (
'ID' int(11) NOT NULL AUTO_INCREMENT,
'RegistrationDate' date NOT NULL,
'IDProd' int(11) NOT NULL,
'Product' varchar(50) NOT NULL,
'Active' tinyint(1) NOT NULL,
'IDUnid' int(11) NOT NULL,
'TipoUnid' varchar(30) NOT NULL,
'Amount' varchar(20) NOT NULL,
'Badroom' varchar(15) DEFAULT NULL,
'Comments' longtext,
PRIMARY KEY ('ID')
) ENGINE=InnoDB AUTO_INCREMENT=1530 DEFAULT CHARSET=latin1;
CREATE TABLE 'Produtos' (
'ID' int(10) unsigned NOT NULL AUTO_INCREMENT,
'Product' varchar(50) NOT NULL,
'IDDesc' int(11) NOT NULL,
'Description' varchar(30) NOT NULL,
PRIMARY KEY ('ID')
) ENGINE=InnoDB AUTO_INCREMENT=64 DEFAULT CHARSET=latin1;
Good morning, I still can not solve my problem, can anyone help?
I leave here the link that allowed me to solve this situation: [ link
But even solving the situation with this video, I appreciate the availability of the community for giving me important tips to reach the solution.