forced value to two Select fields hierarchically connected

This public forum is for user-to-user discussions of PHPMaker. Note that this is not support forum.
Post Reply
jtandrea
User
Posts: 38

forced value to two Select fields hierarchically connected

Post by jtandrea »

hi All.

PHPMaker 12.0.7 here.

I have two Select fields, say: sField1, sField2 plus a Custom Field tChoice

sField1[0] = "Martin"
sField1[1] = "Taylor"
sField1[2] = "Gibson"

sField2[0] = "D28" ("Martin")
sField2[1] = "D35" ("Martin")
sField2[2] = "D41" ("Martin")
sField2[3] = "514" ("Taylor")
sField2[4] = "714" ("Taylor")
sField2[5] = "J45" ("Gibson")

When the user selects sField1 = "Taylor", sField2 is populated only by "514" and "714"
letting him choose between two values, say, 514.

What I want to accomplish, is to have user
to be able to write "514" in tChoice, to force in sField1 = "Taylor" and in sField2 = "514"

is it possible to do so?

Yes I populated both select controls using lookup table.

I tried putting myself known values (with javascript or jquery): onto sField1 succesfully, but it doesn't trigger any event (say click),
and onto sField2 with no luck (until sField2 hasn't inherited sField1 value, it doesn't contain any value at all).

any clue?

regards.


mobhar
User
Posts: 11660

Post by mobhar »

Have you already tried "Dynamic Selection List" in PHPMaker? Please read about that topic from PHPMaker Help menu for more info and example.


jtandrea
User
Posts: 38

Post by jtandrea »

actually I do use "Dynamic Selection List" option.

can you suggest any workaround to trigger the click event onto sField1 (with jquery forced value) so to populate sField2 ?


jtandrea
User
Posts: 38

Post by jtandrea »

code below.

Server Events
Table-Specific
function Page_Load() {
ew_SetClientVar("MyCustomSqlSearchModel", ew_Encrypt("SELECT model, brandname from q_catalog where model='{query_value}'"));
}

Client Scripts
Add/Copy Page
Startup Script

//this is the tChoice field I mentioned before
$("#x_SEARCH_MODEL").change(function () {
var resultSearchModel = ew_Ajax(ewVar.MyCustomSqlSearchModel, $(this).val());
document.getElementById("x_BRANDNAME").value = resultSearchModel[1];
$("#x_BRANDNAME").val(resultSearchModel[1]); //works partially (value is ok but the x_brandname Select reacts as if it wasn't really selected)
$("#x_MODEL").val(resultSearchModel[0]); //doesn't work because x_model actually is empty (x_brandname didn't trigger click event)
});

regards


mobhar
User
Posts: 11660

Post by mobhar »

Try change this:
$("#x_BRANDNAME").val(resultSearchModel[1]); //works partially (value is ok but the x_brandname Select reacts as if it wasn't really selected)
$("#x_MODEL").val(resultSearchModel[0]); //doesn't work because x_model actually is empty (x_brandname didn't trigger click event)

to:
$("#x_BRANDNAME").val(resultSearchModel[1]).change();
$("#x_MODEL").val(resultSearchModel[0]).change();


jtandrea
User
Posts: 38

Post by jtandrea »

hi mobhar, it worked perfectly! thanks very much.


Post Reply