I have an OECGI question. I have an HTML form with a multiple selection field, and inet_queryparam only returns the first value of the field. Since the CGI query string looks something like this:
?vendors=Company1&vendors=Company2&vendors=Company3&vendors=Company4
and…
– list=inet_queryparam('vendors')
… returns 'Company1' only, does anyone have any idea how I can parse this multiple selection field into something like a @vm-delimited list?
Brad,
Here's a function I wrote for a different purpose. I have translated my Norwegian explanation to English so you can see what it's about.
As you see I pick my query parameters from Request without using function Inet_QueryParam. You can do the same.
You might even be able to use my code as a basis for your own version of Inet_QueryParam. There is a while loop where I look for the correct parameter. After I find the parameter (at Found=true$) the parameter value is in QueryParamPPos, len(QueryParam). You just append this value to a dynamic array of your own, and change the loop programming so the loop doesn't stop but runs through the whole of QueryParams until all values for the parameter have been picked up and placed in the array.
<code> function Inet_QueryParam_R( Request, ItemName ) /* erstatning for Revelation sin feilaktige Inet_QueryParam. feilen dens er at den ikke håndterer escapete data rett. dersom det f.eks er en escapet & i en query param, dvs kodet som %26, unescaper den til & igjen og lager kludder. feilen er muligens rettet i OI 3.7.2. Revelation sier det er rettet en feil som har med=å gjøre. Revelation sin Inet_QueryParam har 4 parametre: Inet_QueryParam(Request, ItemName, DefaultValue, NewValue) denne har bare de to første. obs. parameteren blir returnert unescapet! ------------------ replacement for Revelation's Inet_QueryParam, which doesn't handle escaped data correctly. example: assume a query parameter itself contains the & character. the browser will send back this character encoded as %26. but Revelation's version of Inet_QueryParam unescapes the %26 back to &, which it afterwards interprets as any other & between parameters. the error is possibly fixed in OI 3.7.2. Revelation say they fixed an error regarding =. Revelation's Inet_QueryParam function has 4 parameters: Inet_QueryParam(Request, ItemName, DefaultValue, NewValue) my version only has the first two ones. (this can be changed quite easily.) */ $insert Logical $insert Inet_Equates declare function UnEscape QueryParams=Request : "&" /* trick */ NumQP=count(QueryParams, "&") Pos=1 Count=0 Found=false$ loop Count += 1 while Count Num then /* too few characters following "%" */ /* abort conversion */ I=Num + 1 end else H1=StringI+1, 1 convert "abcdef" to "ABCDEF" in H1 H2=StringI+2, 1 convert "abcdef" to "ABCDEF" in H2 if index("0123456789ABCDEF", H1, 1) and index("0123456789ABCDEF", H2, 1) then NewString := Char( IConv( H1 : H2, "MX" ) ) I += 3 end else /* characters following "%" not legal hex digits */ /* abort conversion */ I=Num + 1 end end end else NewString := Ch I += 1 end repeat return NewString</code>
- Oystein -
Brad,
Change your CGI query string from…
?vendors=Company1&vendors=Company2&vendors=Company3&vendors=Company4
to…
?vendors=Company1+Company2+Company3+Company4
The "INET_QUERYPARAM" will return…
VENDORS=Company1+Company2+Company3+Company4'
then just…
CONVERT '+' TO @VM IN VENDORS
We have really fixed it in 7.0
Till then, you need code like Oystein's example.
Bob
…or Brad can do it like Richard suggests, but I believe he'll then need a little bit of JavaScript in the html page.
- Oystein -