Forum > Pas2JS
append new params to the searchParams[SOLVED]
(1/1)
krolikbest:
Hi,
it'd be nice to send from my pas2js file something outside. Let's say after pushing WButton it sends to fphttpserver some parameters which then I'm able to catch with aReqest.QueryFields.Values[..] and work with. A little blindly I try something like
--- Code: Pascal [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---WButton.OnClick()var paramsOut3 : TJSURLSearchParams; url : TJSURL; P : TJSObject; begin {http://192.168.1.4:8080/?txt=22} //this is my href p:=New(['url',window.locationString]); url:=TJSURL(p); // now it should be already url.href assigned url.href:=string(p['url']); //but doesn't and I have to make it by hand, showmessage(url.href); //seems to be ok... paramsOut3:=url.SearchParams; //so now time to separate searchParams paramsOut3.append('txt2','12s'); //error: cannot append to 'undefined', why is undefined?end;
So probably I try make it wrong. Someone knows how to modify url by appendin new params from pas2js?
Regards,
----
Also this doesn't seem to be ok
--- Code: Pascal [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} --- url:=TJSURL(window.location); paramsOut3:=url.SearchParams; paramsOut3.set_('txt','34'); //error undefined
krolikbest:
That works.
--- Code: Pascal [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} --- url:=TJSURL.new(window.locationString); paramsOut3:=TJSURLSearchParams.new; paramsOut3:=url.SearchParams; paramsOut3.set_('txt','12s'); console.log(url.href); window.location.href:=url.href; where
paramsOut3 : TJSURLSearchParams;
url : TJSURL;
Navigation
[0] Message Index