[Kss-devel] Changing a form selection
Christian Klinger
cklinger at novareto.de
Fri Mar 23 08:50:57 CET 2007
Balazs Ree schrieb:
> On Thu, 22 Mar 2007 11:49:29 -0700 Rob Campbell wrote:
>
>
>> What is the best way to change the selected option in a form? Here is
>> an example of the form I am using.
>>
>> <select name="licenseClass" id="licenseClass">
>> <option value="Technician">Technician</option> <option
>> value="General">General</option> <option
>> value="Advanced">Advanced</option> <option value="Amateur
>> Extra">Amateur Extra</option> <option value="Novice">Novice</option>
>> <option value="Technician Plus">Technician Plus</option> <option
>> value="None">None</option>
>> </select>
>>
>> The form is being generated by ReMember. Is there a way to change the
>> selection using the licenseClass id? Thank you.
>>
>
>
Hi Rob,
if i understand you correct, you want change your options
in your select box triggerd by an KSS-Event, right?
If thats your usecase you can do something like this:
(it´s not tested)
for x in YOUR_NEW_OPTIONS:
result.extend(['<option value="%s">%s</option>' %(x[0],x[1])])
IKSSComands.replaceInnerHTML('licenseClass', ' '.join(result))
But i don´t know if it´s the right way to do it??
hth Christian
> I don't understand how the changing of the id could do anything with the
> selection.
>
> But answering to the question, no, I don't remember that we have tried
> this actually. (Maybe, Christian Klinger did something similar?) Now I
> just looked up the html specifications, and it says that the initial
> selection can be set by setting the "selected" attribute on the option
> tag (or tags) that are selected.
>
> However, to see if that works if you change it on an already rendered
> page, you must try that, and what's more, you need to try it in all the
> different supported browsers. Because without that you may never know if
> it would actually work.
>
> For example, in IE we run into the problem that if we replace or add one
> or more option tags (as in the second kss demo), they would not change in
> the page. So for example on IE the only way to change the options is to
> replace the entire select, including the select tag itself. It took a
> long time to figure out this.
>
> I am not saying that changing just the selection would raise similar
> issues but testing this would be essential. Also once it works it would
> be worth to make a new demo page in the kss demo product, for being able
> to test this in the automated tests.
>
>
More information about the Kss-devel
mailing list