Foren

RE: [SOLVED] Dynamically create radio buttons?

thumbnail
Michael Poznecki, geändert vor 14 Jahren.

[SOLVED] Dynamically create radio buttons?

Expert Beiträge: 301 Beitrittsdatum: 10.12.08 Neueste Beiträge
Hello all,
I am trying to create a unknown number of radio buttons on my struts jsp page.

Here is what I was trying:

       Map<string,string> choices;
							  
	 choices = new LinkedHashMap<string,string>();
	 String[] choices_data = {"AA", "BB", "CC", "DD", "EE", "FF", "GG" };
	     for (int i=1; i &lt;= choices_data.length; ++i) {
		       choices.put(Integer.toString(i), choices_data[i-1]);
	     }


							  
	%&gt;
	<c:foreach var="item" items="${choices}">
          	<input type="radio" name="rb" value="${item.key}"> ${item.value}
	</c:foreach>
</string,string></string,string>


But nothing shows up on my page. Can anyone help?

Thanks,
Michael
thumbnail
Michael Poznecki, geändert vor 14 Jahren.

RE: [SOLVED] Dynamically create radio buttons?

Expert Beiträge: 301 Beitrittsdatum: 10.12.08 Neueste Beiträge
Thanks to my good friend Albert J Carter-Corbin!!!

I just need to add this line of code to help with variable scope:
pageContext.setAttribute( "choices", choices );
thumbnail
Muhammad Asif, geändert vor 12 Jahren.

RE: [SOLVED] Dynamically create radio buttons?

Junior Member Beiträge: 25 Beitrittsdatum: 11.04.11 Neueste Beiträge
As you have worked with radio buttons, can you please tell how to place the radio buttons horizontally using <aui:input type="radio" /> tag. Thanks in advance.