Atozed Forums
Get two parameter from javascript - Printable Version

+- Atozed Forums (https://www.atozed.com/forums)
+-- Forum: Atozed Software Products (https://www.atozed.com/forums/forum-1.html)
+--- Forum: IntraWeb (https://www.atozed.com/forums/forum-3.html)
+---- Forum: English (https://www.atozed.com/forums/forum-16.html)
+----- Forum: IntraWeb General Discussion (https://www.atozed.com/forums/forum-4.html)
+----- Thread: Get two parameter from javascript (/thread-2623.html)



Get two parameter from javascript - matija - 01-17-2022

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;


RE: Get two parameter from javascript - Alexandre Machado - 01-19-2022

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)?


RE: Get two parameter from javascript - Alexandre Machado - 01-19-2022

BTW, it's better to execute JavaScript directly

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