This topic is locked

Autofill with int

7/18/2011 5:14:41 AM
PHPRunner General questions
B
bluedude author

Hi,
I have a dropdown with a lookup. When selecting a title from the list I want another INT field to be filled with the selected value. I tried Autofill to do this but that does not seem to work.
Any suggestions?

C
cgphp 7/18/2011

Autofill works fine. Please, explain what you do in more detail.

B
bluedude author 7/18/2011

There is no more detail, I just want to use autofill.
So as said I have a lookup field with titles and values from another table. When selecting one of these I want to fill another field INT of the current table. That's it,nothing more that I can explain.
Do all the fields that you want to autofill need to be on the add/edit page?
Cheers,

C
cgphp 7/18/2011



Do all the fields that you want to autofill need to be on the add/edit page?


Strange question. Autofill is an AJAX call, if the target field is on the add/edit page, it will be filled.

If the target field (the field that you want to autofill) is not on the add/edit page, what do you autofill ?

B
bluedude author 7/18/2011

Well,
I thought it would fill the fields you select on the background without the need to have them on the page (a normal use case scenario because you can pick target fields). So I need to add my INT field, can it be readonly?
I actually think I tried that but will do again.
Cheers,

B
bluedude author 7/18/2011

Tried it again and put in on the page but no luck. Also no error messages when I debug in the browser. For sure both fields are INT and the one I select in the dropbox has a value.
Cheers,

B
bluedude author 7/18/2011

Could a Javascript OnLoad event on another field be the problem?

C
cgphp 7/18/2011



So I need to add my INT field, can it be readonly?


Yes, it can be readonly. Changing the dropdown value the readonly field will not show the int value but it will be saved in the db.

C
cgphp 7/18/2011



Could a Javascript OnLoad event on another field be the problem?


When you change the dropdown value, in the firebug console, you should see an AJAX GET request. Check the corresponding answer from the server.

B
bluedude author 7/18/2011

Well, I discovered the problem. The dropdown autofill does not like code in the Javascript OnLoad. Although I check an onChange on another dropdown this influences also my autofill.
BTW, tested readonly without all my code but that does not work for me.
Anyway, will try to solve it myself.

C
cgphp 7/18/2011



Well, I discovered the problem. The dropdown autofill does not like code in the Javascript OnLoad. Although I check an onChange on another dropdown this influences also my autofill.
BTW, tested readonly without all my code but that does not work for me.
Anyway, will try to solve it myself.


Very strange. Every element in the page has a different selector, so the onChange event on another dropdown shouldn't influence the autofill.

It's hard to say what's happening if I don't see your code.