Web Connection
QueryString question
Gravatar is a globally recognized avatar based on your email address. QueryString question
  Chris Jewell
  All
  Jul 28, 2019 @ 11:34am

Hi Rick,

I'm using the following bootstrap code to allow users to do a search query :

<div class="container">
	<div class="row">
		<div class="col-md-4 col-md-offset-3">
			<form action="" class="search-form">
				<div class="form-group has-feedback">
					<label for="search" class="sr-only">Search</label>
					<input type="text" class="form-control" name="SDAsearch" id="search" placeholder="Enter name\post code.....">
					<span class="glyphicon glyphicon-search form-control-feedback"></span>
				</div>
			</form>
		</div>
	</div>
</div>

I'm using a function I built to generate this dynamically, but the issue I'm having is the 'QueryString' is losing its variables, for example, the original 'QueryString' might look like this :

http://localhost/CSWebApp/SelectDeliveryAddress.cw?Job=N8660&ReturnPath=DespatchJob.cw?Job=N8660

But if I then do a search on this screen, the 'QueryString' changes to :

http://localhost/CSWebApp/SelectDeliveryAddress.cw?SDAsearch=GU51

Whereas I want to to look like this :

http://localhost/CSWebApp/SelectDeliveryAddress.cw?Job=N8660&ReturnPath=DespatchJob.cw?Job=N8660&SDAsearch=GU51

So my question is, how do I preserve the original 'QueryString' when I do a search?

Many thanks, Chris

Gravatar is a globally recognized avatar based on your email address. re: QueryString question
  Harvey Mushman
  Chris Jewell
  Jul 29, 2019 @ 11:07am

Where is the code that calls back to the server?

The concept would be to add the one request to another request. That would be done in your javaScript code. You will need to also have a way to clear prior requests.

I guess you could store the prior requests on the server within the users session but I think that might be a lot more messy.

Show more of your code.

Gravatar is a globally recognized avatar based on your email address. re: QueryString question
  Chris Jewell
  Harvey Mushman
  Jul 29, 2019 @ 01:56pm

Hi Harvey,

Thanks for coming back to me.

My full code is as follows :

*****************************************
FUNCTION SelectDeliveryAddress()
*********
IF Session.GetSessionVar("loggedin")<>"Y"
	Response.Redirect("UserLogin.cw")
	RETURN .f.
ENDIF

cSDAOriginalQueryString = "SelectDeliveryAddress.cw"

cSDAKey = ALLTRIM(UPPER(Request.QueryString("Job")))
IF VARTYPE(cSDAKey)<>"C"
	cSDAKey = ""
ENDIF
IF !EMPTY(cSDAKey)
	cSDAOriginalQueryString = cSDAOriginalQueryString + "?Job="+cSDAKey
ENDIF

cSDAReturnPath = ALLTRIM(UPPER(Request.QueryString("ReturnPath")))
IF VARTYPE(cSDAReturnPath)<>"C"
	cSDAReturnPath = ""
ENDIF
IF !EMPTY(cSDAReturnPath)
	cSDAOriginalQueryString = cSDAOriginalQueryString + "?ReturnPath="+cSDAReturnPath
ENDIF

cSDASearchString = ALLTRIM(UPPER(Request.QueryString("SDASearch")))
IF VARTYPE(cSDASearchString)<>"C"
	cSDASearchString = ""
ENDIF

cSDAAlias = ALIAS()
cSDARetVal = ""
cSDAHeaderMessage = ""
USE sadd IN 0 ORDER sadd ALIAS SDA_Sadd AGAIN SHARED

IF EMPTY(cSDASearchString)
	SELECT * FROM SDA_Sadd INTO CURSOR CurSDASadd ORDER BY name
ELSE
	cSDAHeaderMessage = GetBootStrapAlert("Data filtered for: "+cSDASearchString,"INFO",cSDAOriginalQueryString)
	lcSDAFilterInfo = "Name and\or Post Code contains "+cSDASearchString
	SELECT * FROM SDA_Sadd ;
	WHERE (ATR(name) LIKE '%'+au(cSDASearchString)+'%') OR (ATR(post) LIKE '%'+au(cSDASearchString)+'%') ;
	INTO CURSOR CurSDASadd ORDER BY name
ENDIF
lnCount = _Tally
Close_Table('SDA_Sadd')

Response.WriteLn( this.PageHeaderTemplate("Delivery Addresses"))

IF EMPTY(cSDAKey)
	cSDAJobDelvNotes = ""
ELSE
	cSDAJobDelvNotes = DisplayMemo(GETTABLEFIELDSEEK("Tnote","Tnote",cSDAKey,"dnot","M"))
	IF EMPTY(cSDAJobDelvNotes)
		cSDAJobDelvNotes = "**No Packing & Delivery Notes Entered**"
	ENDIF
ENDIF
	
IF EMPTY(cSDAKey)
	Response.Write("<h1>Delivery Addresses</h1>")
ELSE
	IF GETTABLEFIELDSEEK("job","job",cSDAKey,"splt","L")
		Response.Write("<h1 class='text-danger'>Split Delivery</h1>")
		Response.Write("<h2>Please select the required delivery address before continuing</h2>")
	ELSE
		Response.Write("<h1>Please select the required delivery address before continuing</h1>")
	ENDIF
	cSDACurrentSCode = GETTABLEFIELDSEEK("job","job",cSDAKey,"scode","C")
	cSDACurrentClCode = GETTABLEFIELDSEEK("job","job",cSDAKey,"code","C")
	
	cSDANotes = "<div class='card-deck'>"
	cSDANotes = cSDANotes + "  <div class='card border-info mb-3'>"
	cSDANotes = cSDANotes + "	<div class='card-body'>"
	cSDANotes = cSDANotes + "	 <h4 class='card-title'>Current Delivery Address</h4>"
	cSDANotes = cSDANotes + "	  <p class='card-text'>"+ IIF(!empty(cSDACurrentSCode),GetSaddAddress(cSDACurrentSCode),GetClAddress(cSDACurrentClCode)) +"</p>"
	
	
	cSDANotes = cSDANotes + [<input type="button" id="btnDone" value="Use this address" class="btn btn-primary" onclick="location.href=']+cSDAReturnPath+[&Scode=]+IIF(!empty(cSDACurrentSCode),cSDACurrentSCode,'CL')+['" />]
	
	cSDANotes = cSDANotes + "	</div>"
	cSDANotes = cSDANotes + "  </div>"
	cSDANotes = cSDANotes + "  <div class='card border-info mb-3'>"
	cSDANotes = cSDANotes + "   <div class='card-body'>"
	cSDANotes = cSDANotes + "    <h4 class='card-title'>Packing & Delivery Notes</h4>"
	cSDANotes = cSDANotes + "     <p class='card-text'>" + cSDAJobDelvNotes + "</p>"
	cSDANotes = cSDANotes + "    </div>"
	cSDANotes = cSDANotes + "   </div>"
	cSDANotes = cSDANotes + "  </div>"
	Response.Write(cSDANotes)
ENDIF

Response.Write("<br>")

IF !EMPTY(cSDAHeaderMessage)
	Response.WriteLn(cSDAHeaderMessage)
ENDIF

Response.WriteLn(GetHTMLSearchBar("Enter name\post code.....","SDA")) && HARVEY - This is where my search bar is injected, but when that is submitted it loses the parsed URL and just uses the plain URL but with the search QueryString.

loConfig = CREATEOBJECT("HtmlDataGridConfig")
loConfig.PageSize = 10
loConfig.CssClass = "table table-striped small"
TEXT TO cHtmlBtn noshow
	HtmlButton("btnDone","Select",[class='btn btn-primary ' onclick="location.href=']+cSDAReturnPath+"&Scode="+CurSDASadd.Code+['"])
ENDTEXT
loConfig.AddColumn(cHtmlBtn,"Options:")
loColumn = loConfig.AddColumn("Name","Name")
loColumn = loConfig.AddColumn("A1","Address 1")
loColumn = loConfig.AddColumn("A2","Address 2")
loColumn = loConfig.AddColumn("A3","Address 3")
loColumn = loConfig.AddColumn("A4","Address 4")
loColumn = loConfig.AddColumn("A5","Address 5")
loColumn = loConfig.AddColumn("POST","Post Code")
loColumn = loConfig.AddColumn("CONT","Contact")

lcHtml = HtmlDataGrid("CurSDASadd",loConfig)
Response.Write(lcHtml)
Response.Write( this.PageFooterTemplate() )  
Close_Table('CurPIWHDesp')

ra(cSDAAlias)
RETURN cSDARetVal

ENDFUNC

Maybe I should ask a different question, how would you recommend having a search option that keeps the URL intact?

Thank you for helping me 😃

Regards,

Chris

Gravatar is a globally recognized avatar based on your email address. re: QueryString question
  Rick Strahl
  Chris Jewell
  Jul 30, 2019 @ 05:09am

The. Alien of the url in your query string needs to be urlencoded - the ? In the query string is invalid and probably breaks the url...

Rick

© 1996-2024