I used to do it that way too.  It involved a lot of coding and my HTML editor's 
checking routine didn't like the substitution variable inside the option tag.  
Also, each option tag had to be coded in the HTML in the template.

This is what led me to write CrtTagOpt.

CrtTagOpt's disadvantage is that the option choices have to be handled in the 
program, but this can be turned into an advantage by putting all the choices, 
text, and defaults into a database file.  Making changes to the selection boxes 
then becomes as simple as modifying records in the database file.

Here is an example of how to code it.

The HTML template might look something like this:

/$option
/%option%/

/$select
<select>

/$endselect
</select>

The RPG might look something like this, where selectedchoice = the option that 
was selected; choices and choicestext are arrays of possible option values and 
text.  I'm using arrays for illustrative purposes.  In the real world, a 
database file might be used.

callp WrtSection('select')
for i = 1 to choices
  callp UpdHtmlVar('option':CrtTagOpt(choices(i):choicestext(i):selectedchoice))
  callp WrtSection('option')
endfor
callp WrtSection('endselect')

One of my customer's applications had many selection boxes.  We built a 
database file containing all the text, values, and defaults and used CrtTagOpt 
exclusively.  For optimal performance, the CGI program loaded the database 
information into dynamically allocated storage.


Mel Rothman, CGIDEV2 Author
IBM eServer Custom Technology Center (eCTC), Rochester, Minnesota
http://www-1.ibm.com/servers/eserver/iseries/service/ctc/
http://www.easy400.ibm.it/en


"Goodbar, Loyd (AFS-Water Valley)" wrote:
>
> If your CGIDEV2 template looks like this...
>
> /$select
> <select>
> <option /%selecteda%/>A</option>
> <option /%selectedb%/>B</option>
> <option /%selectedc%/>C</option>
> </select>
>
> The first time you display the template, just set the variables to no
> string:
> c callp updhtmlvar('selecteda':'')
> c callp updhtmlvar('selectedb':'')
> c callp updhtmlvar('selectedc':'')
>
> On subsequent form returns, you can dynamically turn on the select status
>
> c if option = selectedoption
> c callp updhtmlvar('selected'+%trim(option) : 'selected' )
> c else
> c callp updhtmlvar('selected'+%trim(option) : '')
> c endif
>
> This is a way of doing it without explicitly generating the select
> information programmatically. CGIDEV2 might have a better way, but I haven't
> explored it fully.
>
> HTH,
> Loyd
>
> -----Original Message-----
> From: Bartell, Aaron L. (TC) [mailto:ALBartell@taylorcorp.com]
> Sent: Monday, January 14, 2002 9:24 AM
> To: 'web400@midrange.com'
> Subject: RE: [WEB400] First Internet application
>
> I have a question about putting HTML in the CGI program.  If I have
> drop-down list box is there a way for me to return back to the user what
> they selected without dynamically coding the <select> tag in RPG.  For
> example if I outputted this HTML the first time:
>
> <select>
> <option>A</option>
> <option>B</option>
> <option>C</option>
> </select>
>
> and the user selected option C.  So now when I re-display the page I want
> that to be selected I now have to code the select statement like this:
>
> <select>
> <option>A</option>
> <option>B</option>
> <option selected>C</option>
> </select>
>
> Is there a way to do this in a template?
>
> I have gone the route where I try to have as much HTML in the IFS as
> possible, and then I read it into my program at the appropriate time.  But I
> have noticed that it comes to a point where I forget what pieces of HTML I
> coded in my program what I coded in the IFS so I start a hide and seek game.
> So right now I code most off my HTML in my CGI programs and bigger chunks of
> HTML in the IFS.
>
> >From what I have read CGIDEV would fix most of my problems and I just need
> to take the time to learn it.
>
> Aaron Bartell
> _______________________________________________


As an Amazon Associate we earn from qualifying purchases.

This thread ...

Replies:

Follow On AppleNews
Return to Archive home page | Return to MIDRANGE.COM home page

This mailing list archive is Copyright 1997-2024 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].

Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.