0

I'm trying to use the <sj:select> as a double select, where the value from the first select should be used as a input parameter for the second select.

First select:

<s:url id="remoteurlKontor" namespace="/json" action="getKontor"/>  
<sj:select  label="Kontor" 
            href="%{remoteurlKontor}" 
            id="franKontor" 
            name="franKontor" 
            onChangeTopics="reloadsecondlist" 
            list="kontor" 
            listKey="kontorKod" 
            listValue="kodAndNamn" 
            emptyOption="true" 
            headerKey="-1" 
            headerValue="Välj kontor"
/>

Second select

<s:url id="remoteurlSektion" namespace="/json" action="getSektionskoder" /> 
<sj:select  label="Sektion" 
            href="%{remoteurlSektion}" 
            id="franSektion" 
            name="franSektion"
            reloadTopics="reloadsecondlist"  
            list="sektionsKoder"
            emptyOption="true" 
            headerKey="-1" 
            headerValue="Välj Sektion"
            onSelectTopics="check"
/>

I want the chosen value from the first select to go as argument in href="%{remoteurlSektion}" so the URL will be like /json/getSektionskoder.action?kontorskod=0515 in the second select.

Anyone know if it's possible?

dvalfrid
  • 1
  • 2
  • I guess it would be easier to do this with the rendered HTML Code and using jQuery or Plain Javascript. Make sure you add the jquery library into the top of the file and and also if you are computing the select values using an external JS file. Add it in the top of the JSP doc or in your layout file. If you need to know how to get the select value using Javascript this link might be useful for you http://stackoverflow.com/questions/4029281/get-drop-down-value – Ravi Aug 28 '12 at 15:25
  • 1
    There's a [doubleselect example on the wiki](http://code.google.com/p/struts2-jquery/wiki/SelectTag#A_simple_Doubleselect_with_Topics), did you try it? – Dave Newton Aug 28 '12 at 17:04
  • I used the example to get this far, but the problem with the example is that both the json methods and the jsp pages needs to be in the same action. Both my json methods are in different actions and they cant share attributes with each other. – dvalfrid Aug 28 '12 at 20:13

1 Answers1

1

Sure it is possible. See the Example in the Showcase App. There is an example under AJAX Form / AJAX SELECT (Doubleselect).

Are both tags inside the same form? Else you should specify formIds attribute in your second tag.

Johannes
  • 2,060
  • 3
  • 17
  • 27
  • It does not solve my problem, the json methods are in different actions, so they cant share attributes on the server side. – dvalfrid Aug 28 '12 at 20:14