Hi!
I'm struggling with the following problem and would be grateful if you could help:
I have a multiple select field:
Please note that the name is "fields[]", thus an array, because I want to be able to access all selected options values $_POSTed on the next page. So far this works.
The problem is that I have to fill the select menu dynamically (the values for the options come from a database) with JScript.
If my select menu was not multiple, thus if i name it only "fields" instead of "fields[]", I know hot to e.g. add new options:
How do I have to modify the addOption function, so that i can insert options to the "fields[]" array?
And how will the function be called then,
addOption(document.all.fields[], text, value); ??
Thanks already now for your help!
c.
I'm struggling with the following problem and would be grateful if you could help:
I have a multiple select field:
Code:
<select multiple size="5" name="fields[]">
<option value ="value">option1</option>
...
</select>
The problem is that I have to fill the select menu dynamically (the values for the options come from a database) with JScript.
If my select menu was not multiple, thus if i name it only "fields" instead of "fields[]", I know hot to e.g. add new options:
Code:
addOption(document.all.fields, text, value);
Code:
function addOption(selectObject, optionText, optionValue) {
var optionObject = new Option(optionText,optionValue);
var optionRank = selectObject.options.length;
selectObject.options[optionRank]=optionObject;
}
And how will the function be called then,
addOption(document.all.fields[], text, value); ??
Thanks already now for your help!
c.