Atozed Forums

Full Version: Get two parameter from javascript
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
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;
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)?
BTW, it's better to execute JavaScript directly

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