next day, next question 😟 😉
i have a dropdown with data filled by a database. This works fine so far. The value key is the ID of the database table. Now i want to fill some elements with data related to the choosen id. My plan:
1. creat a CHANGE event for the dropdown
2. using a PHP - query to read data from database filtered by the dropdown value
3. Fill the form elements with the data.
For a more easy start i canceld point to and point 3 is set the values to a fixed string.
I tried the following things:
1. At the dropdown in the Form : Addes 2 events
1.1. on "=" --> Value selected : 1 --> Aktion : function --> field id, fn() or event : change
1.1. on "!=" --> Value selected : 1 --> Aktion : function --> field id, fn() or event : change
2. I Added a textbox to the form with Field Name = info_vn and Field ID = info_vn
3. At Setup --> On Load i added a Load Java Script
[list]
window.addEvent('domready', function() {
$('dd_player').addEvent('change', function() {
$('info_vn').value = 180;
});
[/list]
--> i does not work 😟 Can someone help me ?
the next step in my mind is to change the code for the function to something like this
[list]
<?php
$db =& JFactory::getDBO();
$query = "
SELECT `id`, `player_nn`, `player_vn`,`player_hcp`
FROM `#__data_player`
WHERE `id` = '{$form->data['dd_player']}';
";
$db->setQuery($query);
$row = $db->loadAssoc();
'{$form->data['player_vn']}' = $row['player_vn'];
?>
[/list]
is this realistic ? or is there a much better way to do it ?
Regards from Germany
TRIJ