How to show a textfield dynamically using struts..(URGENT)
Joined: Jan 21, 2007
Hi everyone.. I want to know how to show or hide a text filed based on the value selected in a Drop down List. Say for example i have created a DropDownList which has numbers 1,2,3 using the <html:select> tag &<html ptionsCollection> tag. Now if i need to display 1 textfield if the user has selected 1 from dropdownlist, 2 textfields if user has selected 2 from the list.
Can someone please help me by providing a sample code.I need it very badly.
Thanks in Advance For your help.
Joined: Jan 24, 2008
hi, for this you can write a code in your action such that take the selected value in that dropdown list and based upon that set some boolean value/set some property in the form to 1/2/3/4 which ever you want. and in the JSP you can use <logic:equal name="formName" property="thePropertyyouHaveSetInForm" value="1/2/3/4..."> give the Text box here.</logic:equal>.
Basically you have to get the dropdown list value in your action and based upon that you have to set a property to 1or2or3or4 and can use the logc:equal tag.
Test and let me know if this had helped you... Good Luck!!!