I want to show and hide some tags based on the selection in the drop down list.
The code in jsp
How can we use Dojo tags to accomplish the same?
I tried using JQuery for the same.I could use it with html tags and it was working but not with struts 2 tags.
Any tutorials available???
Please guide me!!!
This seems to be a simple problem to me. In the show_detail method, you can call document.getElementById('Register:Workselect').selectedIndex (you can also use document.getElementById('Register:Workselect').options with it) to find out which element is selected. Then depending upon that you can make the divs visible or hidden using document.getElementById('box').style.display = 'none' or 'block'.
(As far as I remember, struts ads the form name to the id of form fields in the form but I don't remember if struts uses : between them or something else)
I don't think it's valid HTML to have a DIV nested in a FORM (that may depend on which version of HTML you're targeting, though).
It's actually a bit problematic to access the table row of a form element and its label at the moment. That may have been (at least partially) addressed in the "css_xhtml" theme, and I'm planning on adding it to the "xhtml" theme (and "css_xhtml" if it's not already there) but haven't had a chance.
Your quickest solution might be to just take whichever theme you're using and modify it to include suitable "id" attributes on the table rows (or DIV elements if you're using "css_xhtml"), or wait for the next release (I think I missed 2.1.7).
Joined: Aug 08, 2008
Thanks for your reply David.
Actually it works if i enclose it just within normal <form> </form> tag.
but not inside <s:form> </s:form> tag.
It will not work with struts tags is it?
If you're using the default "xhtml" theme then using S2 form input elements without the <s:form> tag will produce *completely* invalid HTML, whereas embedding the div tags inside the table is invalid but might work.
Without knowing what theme you're using it's impossible to tell you much more than that.
Joined: Aug 08, 2008
Yeah actually i was using the default theme till now and i was trying with Dojo and JQuery tags.
It dint work.
I tried giving theme as "ajax" and its working fine with JQuery.
Tat shows my ignorance
I have a struts form, depending on the select option the div should show/hide and the div contains textfields. Am using jquery for show/hide div. The textfields within div are not behaving right. When I keep the theme as "simple", The textfields hide and on option selection they show up but the label to the textfield does not show up and the alignment is bad. If the Theme is "ajax" or "qxhtml" or "xhtml", the textfields hide/show properly but the labels of textfields do not hide. Is there a good compromise between the layout and the hide/show functionality?