0
Good morning,
I have this form where comboboxes already show the desired values: [! [Fromulary][1]][1]
Now I have a problem, because I while selecting the product, I want it to appear on the label "Unit" automatically the product unit.
This is the code I used to fill the combobox "Product":
<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 of 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, someone can help?
I leave here the link that allowed me to resolve this situation: [https://www.youtube.com/watch?v=_9RXHMn57Gk][2]
But even solving the situation with this video, I thank the community for giving me important tips to reach the solution
And what the value of unity and where it comes from?
– Woss
the unit value comes from the mysql database. The product combobox query comes from the products table and only has the id and product fields and the unit comes from the Unid type table and has the id, unit and idprod fields which is equal to the product id.
– user77403
you’ll have to use
jquery
withajax
to do this– djva
And can you set an example for me to try to do? This is the first time I’m doing this
– user77403