Onclick not worlking

I have 2 fields with “text autocomplete” (field in database is integer) without “use select2” which and I want to fill with the result of an ajax onclick.

{field1} = 715 and {field2) = 0

or depending of your choice (radio button) the other way around.

{field1} = 0 and {field2} = 715

However this does not work. It does not pass the values.

How to solve?

Regards, Bert

Write some JavaScript that parses the form’s DOM, watch for changes to either field, and after, say, one second, POST the appropriate corresponding value to the other field.

Being an unpredictably-timed behavior, it will be very easy to break that code and get incorrect values in the fields, so check their validity in onBeforeUpdate, or onBeforeInsert events.

The lesson: Never try to make a browser app behave like a console (Qt, .NET, Java etc) app. It won’t behave that way and users will call you, or data will get hosed and managers will call you.

I think there is a misunderstanding. I donot want to fill the field in the client. I simply working in a sc form with fields. Normaly by passing {field1} = 715 or a variable like {field1} = $test then after pushing save it is in the table

@cmtservice, your description is really not clear to me:

  • which fields are the autocomplete ones (field1 and field2?) and are they virtual (created in the form) or db ones
  • which field is the radio button (a third field?)
  • on which field's onchange event (the radio button field?) you want to update which other field(s) and with what values(s)

Let me be more clear.

I have made a radio button on a field, lets call the field in the database radio1
In the radio1 I made manualy choice1 with the value 1 and choice2 with the value 2
So when you click on the radio the result is depending of your choice 1 or 2.

Now I made a ajax event onclick on the radio1 with the script:

If ({radio1} == 1){
{field1} = 0;
{field2} = 715;
}

If ({radio1} == 2){
{field1} = 715;
{field2} = 0;
}

So the field1 is of the type textcomplete and the field2 is also a textcomplete

The aim is depending of your choice that the field1 and field2 is filled with the values.

THE GOOD NEWS:
After I got an update this afternoon the system works fine.

.