Forum Moderators: open
var userOptions = {
consumer: [{value: 'option1', label: 'Option 1'},...],
professional: [{value: 'option3', label: 'Option 3'},...]
};var options = userOptions[userType];
Then you need to create a select element and load the options into it:
var select = document.createElement('select');
options.each(function(o){
var option = document.createElement('option');
option.value = o['value'];
option.textContent = o['label'];
select.appendChild(option);
});
$('container').appendChild(select);
NB. I used the Prototype.js specials 'each()' and '$()' in there, but it's simple to use generic JS functions in their place. Also, it's totally untested but should give you the gist of how to do it.
But really, this probably isn't what you're looking for. You probably want to use a server side language. Or perhaps server-side scripting with a little JS (like Prototype.js' Element.toggle()) to make it spiffy.