HI All,
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]
--> 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]
is this realistic ? or is there a much better way to do it ?
Regards from Germany
TRIJ
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
Hi TRIJ,
If you only have a small amount of data linked to each option then it might be simpler to use the data attribute in the <option> tags to add the data when the form is created. Please see this FAQ which has a simple example for CFv4. This could be extended to handle the three items that you are getting.
Bob
If you only have a small amount of data linked to each option then it might be simpler to use the data attribute in the <option> tags to add the data when the form is created. Please see this FAQ which has a simple example for CFv4. This could be extended to handle the three items that you are getting.
Bob
HI Bob, Hi All,
i have read a lot of FAQ' and Forum Text but sadly i cant get the last step :? I still have the problem, that i want to autofill the value of a textbox by changing the selection from a dropdown. In the FAQ's i found the explenation how to create a double DropDown with dynamic data from database.
Set to events on a first Dropdown for = ' ' and != ' ' ... Set it to get Dynamic option and link it to a second dropdown with the optionlist creating by an ajax_event.
In my oppinion i have nearly the same problem..But instead of creating an option list for a secon dropdown i want to change the value of a textbox. Therefor i have to change the "field id" from the second drobdown_id to the textbox_ id. ... And now ????
... Is the Action still Set Dynamic Options or do i have to change this to function?
... in the Ajax event i need as a result the change of textbox value and not an option List.
Sorry for the stupid questions. But i feel there are different ways to solve the problem ... shown in the forum ... but i always have the feelingh of missing some steps.
i have read a lot of FAQ' and Forum Text but sadly i cant get the last step :? I still have the problem, that i want to autofill the value of a textbox by changing the selection from a dropdown. In the FAQ's i found the explenation how to create a double DropDown with dynamic data from database.
Set to events on a first Dropdown for = ' ' and != ' ' ... Set it to get Dynamic option and link it to a second dropdown with the optionlist creating by an ajax_event.
In my oppinion i have nearly the same problem..But instead of creating an option list for a secon dropdown i want to change the value of a textbox. Therefor i have to change the "field id" from the second drobdown_id to the textbox_ id. ... And now ????
... Is the Action still Set Dynamic Options or do i have to change this to function?
... in the Ajax event i need as a result the change of textbox value and not an option List.
Sorry for the stupid questions. But i feel there are different ways to solve the problem ... shown in the forum ... but i always have the feelingh of missing some steps.
The other way i tried was a JS code like this
[list]
but i cant get managed, that in the Form anything happend. Doesent matter what i do ... The Textbox Values are never changing ...😟
Best Regards TRIJ
[list]
window.addEvent('domready', function() {
$('dd_player').addEvent('change', function() {
$('player_vn').value = 'a';
$('player_nn').value = 'b';
$('player_hcp').value = 'c';
});
});
[/list]
but i cant get managed, that in the Form anything happend. Doesent matter what i do ... The Textbox Values are never changing ...😟
Best Regards TRIJ
This topic is locked and no more replies can be posted.