This topic is locked

Auto fill multiple fields from one dropdown box

8/6/2010 8:44:44 AM
PHPRunner General questions
S
swanside author

Hello.
I have an add page with 45 fields on it. They are all dependant on one table and one field being selected.

Is there a quick way of making all the fields fill in with the correct values from using just one dropdown box?

Cheers

Paul.

F
FunkDaddy 8/6/2010

Use the "insert button" feature in Visual Editor... then you will be able to use javascript to capture values of the main field you want the other 45 fields to be based on upon (their dependency)... use the Server Side code to query the data to be used for those fields based on the main field) then return the parameters and use Javascript After client to populate the fields on the page.
Read this post... you will need to fix a bug in PHPRunner first...
http://www.asprunner.com/forums/topic/14923-insert-button-feature-to-update-field-during-add-page/
The only drawback with the solution is that you must "click" the button for those fields to be populated on your form... however, you can also use a javascript onchange event that will fire once your main field changes that would tell javascript to click that button for you. It would look something like this "document.getElementById("New_Button").click();"
Hope this helps.

romaldus 8/6/2010



Use the "insert button" feature in Visual Editor... then you will be able to use javascript to capture values of the main field you want the other 45 fields to be based on upon (their dependency)... use the Server Side code to query the data to be used for those fields based on the main field) then return the parameters and use Javascript After client to populate the fields on the page.
Read this post... you will need to fix a bug in PHPRunner first...
http://www.asprunner.com/forums/topic/14923-insert-button-feature-to-update-field-during-add-page/
The only drawback with the solution is that you must "click" the button for those fields to be populated on your form... however, you can also use a javascript onchange event that will fire once your main field changes that would tell javascript to click that button for you. It would look something like this "document.getElementById("New_Button").click();"
Hope this helps.


BTW is it possible to use AJAX to update other fields automatically after dropdown value selected instead of using button?

A
ann 8/9/2010

Paul,
use JavaScript Onload Event on the Events tab.

Here is a sample:

var ctrl = Runner.getControl(pageid, 'FieldName');

var ctrl1 = Runner.getControl(pageid, 'FieldName1');

var ctrl2 = Runner.getControl(pageid, 'FieldNam2');



function func() {

ctrl1.setValue(ctrl.getValue());

ctrl2.setValue(ctrl.getValue());

...

};



ctrl.on('change', func);



you can also set up them as dependent dropdowns.

S
swanside author 8/9/2010



Paul,
use JavaScript Onload Event on the Events tab.

Here is a sample:

var ctrl = Runner.getControl(pageid, 'FieldName');

var ctrl1 = Runner.getControl(pageid, 'FieldName1');

var ctrl2 = Runner.getControl(pageid, 'FieldNam2');
function func() {

ctrl1.setValue(ctrl.getValue());

ctrl2.setValue(ctrl.getValue());

...

};
ctrl.on('change', func);



you can also set up them as dependent dropdowns.



Thanks Ann.

I set them up as dependant dropdowns.

Cheers