Take the 2-minute tour ×

I have written one code to appear a text box when selecting Other option from a dropdown list. The function for this is as below: (I have not mention the dropdown list code, if required please let me know)

function showfield(name)
        if(name=='Other')document.getElementById('div1').innerHTML='<input type="text" property="otherCategory" size="25" />';

        else document.getElementById('div1').innerHTML='';

I am using Struts framework and have written getters/setters in registrationForm.java for otherCategory. But in the actionForm named registrationFormAction.java, after submitting the form, the value is not passing to the action form. Other values I am able to get. Means I am not able to get the value by registrationForm.getOtherCategory() in the registrationFormAction.java.

For other fields I am writing the code as

<html:text property="Name" size="25">

I also tried using <input type="text" name="otherCategory"/> but I am not sure how to pass the value to the action form registrationForm.java when I use name="otherCategory". Hopefully I am able to explain my problem, would appreciate someone's help

Thanks. Biswa

share|improve this question
This is struts1. Why do you tag the question with struts2? –  JB Nizet Jan 25 '13 at 8:55

1 Answer 1

property is not a valid attribute of <input>. The field should be <input type="text" name="otherCategory"/>. If it's not submitted, it's probably because the field is outside of the form instead of being inside. But it's just a guess, since you don't provide enough code to know.

Use Firebug or the chrome developer console to know what is being submitted.

share|improve this answer
Thanks Nizet,I tried using name="otherCategory but not sure how to get the value in the actionfrom.The program flow is like In jsp page: function fnSubmit() { document.forms[0].operation.value="saveData"; document.forms[0].submit(); } In RegistrationFormAction.java: public ActionForward saveData(ActionMapping mapping, ActionForm form, HttpServletRequest request,HttpServletResponse response) { //how to get the otherCategory value } –  user2007374 Jan 25 '13 at 9:34
RegistrationForm registrationForm = (RegistrationForm) form; String otherCategory = registrationForm.getOtherCategory();. That's core struts stuff. –  JB Nizet Jan 25 '13 at 9:38
Thanks Nizet, it worked, actually its because of the <input type="text" property="otherCategory" size="25" />, when i changed to input type "name" it worked, thanks again... –  user2007374 Jan 25 '13 at 11:41

Your Answer


