Using webservices I want to create a "page" where the initially selected options in a listbox on a web form are dynamically set based on the user.
The basic approach I imagine is for my webservices URI will call an APL function that determines the options to be selected then creates/edits an html file that is sent to the user's browser with those options selected.
The question I have is how best to create/edit that html file.
Two possible approaches are:
- write the appropriate html code for the options to be selected
(e.g. <option value="toast" selected="selected">Toast</option>) and output the document to webservices.
- write some javascript to the header of the html document that initializes a variable containing an array of the option values to have selected initially. Use the "onload" event to run a javascript function that selects the option values set in the variable when the document is loaded in the user's browser.
Option 1 seems a bit clunky but keeps all the "work" in APL
Option 2 seems more "elegant" and generically useful but is more complicated given the use of both APL & javascript
I'm tending towards Option 2 at this stage but wondered if there are any other options that I'm missing?