php js mysql dropdown selection fills textboxes with db value
Dear stackoverflow users, I am banging my head for a piece of code that
cant be to difficult but somehow my brains are not working today so please
help.
I am creating a form where i want to select an id from an dropdown(this is
working) and after selection i want to see all the records related to the
id in textfields. i want to create the fields manually so i dont want an
autocreate script. this is the code i have so far.
<!--Onderstaande gegevens worden NIET geprint!-->
<div id="non-printable">
<!---->
<?
// Load Joomla! configuration file
require_once('configuration.php');
// Create a JConfig object
$config = new JConfig();
// Get the required codes from the configuration file
$server = $config->host;
$username = $config->user;
$password = $config->password;
$database = $config->db;
// Tools dropdown
$con = mysql_connect($server,$username,$password);
mysql_select_db($database);
$sql = "SELECT cb_dealerid FROM cypg8_comprofiler";
$result = mysql_query($sql);
// Dealergegevens fields
?>
<!--Begin TOOLS-->
<div class="tools">
<div class="dealerselectie">
<?
echo "<select name='cb_dealerid'>";
while ($row = mysql_fetch_array($result)) {
echo "<option value='" . $row['cb_dealerid'] . "'>" . $row['cb_dealerid']
. "</option>";
}
echo "</select>";
?>
</div><!--/.Dealerselectie-->
</div><!--/.Tools-->
<!--Einde TOOLS-->
<!--Begin DEALERGEGEVENS-->
<div class="dealergegevens">
<input type="text" name="cb_dealerid" value='" . $row['cb_dealerid']
. "'><br>
<input type="text" name="cb_dealerbedrijfsnaam" value='" .
$row['cb_dealerbedrijfsnaam'] . "'>
</div><!--/.dealergegevens-->
<!--Einde DEALERGEGEVENS-->
</div><!--/#non-printable-->
<!--Bovenstaande gegevens worden NIET geprint!-->
I know i am doing something wrong but i cant figure out what it is. I need
to create this without using a multipage form it all needs to stay on one
page. Any advice would greatly be appreciated.
Thanks in advance.
EDIT 1:
I keep on trying to get it to work obviously and this is one of the
attempts which is also not working.
<?echo "<input type=\"text\" value='" . $row['cb_dealerid'] . "'>";?>
<?echo "<input type=\"text\" value='" . $row['cb_dealerbedrijfsnaam'] .
"'>";?>
EDIT 2: <== MORE INFORMATION ABOUT WHAT I WANT TO ACHIEVE
I have in my database table the following details
cb_dealerid = 100, 101, 102, 103 cb_dealerbedrijfsnaam = willem, henk,
piet, klaas
When i select in the dropdown id 101 i want to see in the textbox the name
henk.
No comments:
Post a Comment