Get two parameter from javascript

<< Click to Display Table of Contents >>

Navigation:  Forum >

Get two parameter from javascript

Forum link

 


 

01-17-2022, 01:34 PM:

 

How get all parameters if you click button? My code get only first paramater!

 

javascript:

 

var index1 = 0;

 

var index2 = 1;

 

function SelectIndex1() {

 

  return index1.toString();   

 

}

 

function SelectIndex2() {

 

  return index2.toString();   

 

}

 

code:

 

procedure MyButtontAsyncClick ...

 

begin

 

AddToInitProc('ajaxCall("ReceiveIndex1", "&ID=" + SelectIndex1();');

 

  RegisterCallBack('ReceiveIndex1',

 

        procedure (aParams: TStrings)

 

        begin

 

            MapIndex:= StrToIntDef(aParams.Values['ID'],0);

 

            AddToInitProc('GetMap(' + MapIndex +')');

 

        end

 

);

 

AddToInitProc('ajaxCall("ReceiveIndex2", "&ID=" + SelectIndex2();');

 

RegisterCallBack('ReceiveIndex2',

 

procedure (aParams: TStrings)

 

begin

 

ListIndex:= StrToIntDef(aParams.Values['ID'],0);

 

AddToInitProc('GetList(' + ListIndex +')');

 

end

 

);

 

end;

 


 

01-19-2022, 12:38 AM:

 

When calling your application via Ajax (Async) you should send everything in a single call (unless your response triggers another server call, which is useful in some cases, but it's not that common).

 

Can you send both in the same call or do you need the second call to follow the first (call and response)?

 


 

01-19-2022, 12:40 AM:

 

BTW, it's better to execute JavaScript directly

 

WebApplication.CallbackResponse.AddJavaScriptToExecuteAsDATA('ajaxCall("ReceiveIndex1", "&ID=" + SelectIndex1();');