I am guessing in this instance you have not changed the variables I supplied
with the script with your actual form and select names.

var options = document.forms['formName'].elements['selectName'].options;

-----Original Message-----
From: Anja Friedrichsen [mailto:[EMAIL PROTECTED] 
Sent: 06 April 2005 16:24
To: Struts Users Mailing List; [EMAIL PROTECTED]
Subject: Re: change selected item in drop down list

Thanks for your answer Mark,

I am new with JavaScripts and I tried your example, but it does not 
really work...

I tried to do

    alert(options);

after
    var options = form.elements['select'].options[i];


but nothing happend. What exactly is that line doing?

Thanks, Anja



Mark Benussi wrote:


>Yes you can select an option in a selection, but you would need to know the
>index of the option.
>
>form.elements['select'].options[i].selected = true;
>
>When generating the select using the html:options argument your
presentation
>layer wont have much knowledge of the data passed so you will have to
>recurse the options until you find one that matches your selection on the
>map.
>
>function somethingHappened(mapSelection) {
>       var options = form.elements['select'].options[i];
>       for(var i = 0; i < options.length; i++) {
>               var option = options[i];
>               if(option.value == mapSelection) {
>                       option.selected = true;
>                       break;
>               }
>       }       
>}
>-----Original Message-----
>From: Anja Friedrichsen [mailto:[EMAIL PROTECTED] 
>Sent: 06 April 2005 11:20
>To: Struts Users Mailing List
>Subject: change selected item in drop down list
>
>Hi!
>
>My application is based on stuts and contains among other thing a 
>dropdown list and a graph. What I want to do, is to change the selected 
>item in the drop down list, when clicking on the corresponding node in 
>the graph.
>Is it possible to change the selected item in a dropdown list?
>
>My drop down list looks like that:
>
>                      <html:select property="cvIdentification">
>                          <html:options collection="cvIdentifications" 
>property="shortlabel" labelProperty="shortlabel" />
>                      </html:select>
>
>Thanks in advanced!
>
>Anja
>
>---------------------------------------------------------------------
>To unsubscribe, e-mail: [EMAIL PROTECTED]
>For additional commands, e-mail: [EMAIL PROTECTED]
>
>
>---------------------------------------------------------------------
>To unsubscribe, e-mail: [EMAIL PROTECTED]
>For additional commands, e-mail: [EMAIL PROTECTED]
>
>  
>


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to