You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by mike barretta <mi...@atthehip.net> on 2004/03/15 20:35:05 UTC

dynamic javascript forms

thanks in advance for any help...

i have a form where i let the user choose how many text input fields 
they want and then via javascript, the inputs are displayed.

ex: user has a <select> box to make a choice of 1-10.  after selection 
is made, the onChange event will fire and write however many text inputs 
on the screen using the innerHTML property.

my problem is that since javascript changes the screen at runtime, i 
can't use <html:input> to capture the text from the form because it 
isn't being interpreted by struts.  if the javascript uses the standard 
<input type="text"> tags, it seems like my actionform doesn't get 
populated with the data.

so, anyway to do this without having to submit the form after the user 
selects how many inputs they want?


---------------------------------------------------------------------
To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-user-help@jakarta.apache.org


Re: dynamic javascript forms

Posted by Geeta Ramani <ge...@cmpco.com>.
How about usng more Javascript and using onFocus() (or is it onChange()?) to
populate hidden fields which can be picked up by your form bean..? (Not a
solution I like but then i hate most all Javascript..)

regards,
Geeta

mike barretta wrote:

> thanks in advance for any help...
>
> i have a form where i let the user choose how many text input fields
> they want and then via javascript, the inputs are displayed.
>
> ex: user has a <select> box to make a choice of 1-10.  after selection
> is made, the onChange event will fire and write however many text inputs
> on the screen using the innerHTML property.
>
> my problem is that since javascript changes the screen at runtime, i
> can't use <html:input> to capture the text from the form because it
> isn't being interpreted by struts.  if the javascript uses the standard
> <input type="text"> tags, it seems like my actionform doesn't get
> populated with the data.
>
> so, anyway to do this without having to submit the form after the user
> selects how many inputs they want?
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: struts-user-help@jakarta.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-user-help@jakarta.apache.org


RE: dynamic javascript forms

Posted by Robert Nocera <rn...@neosllc.com>.
I'm pretty sure you can do it if the text inputs are set up in the form as
an Array of Strings and if you create your input tags to match what struts
would expect from an array.  If you do that, you can have your javascript
create the fields dynamically as you said.

It sounds like you tried this and it didn't work for you, but I would think
it's probably just because you either didn't use an array setting up the
action form, or you didn't create html input tags that matched what struts
would have created if you used html:input.

-Rob 

-----Original Message-----
From: mike barretta [mailto:mike@atthehip.net] 
Sent: Monday, March 15, 2004 2:35 PM
To: struts-user@jakarta.apache.org
Subject: dynamic javascript forms

thanks in advance for any help...

i have a form where i let the user choose how many text input fields 
they want and then via javascript, the inputs are displayed.

ex: user has a <select> box to make a choice of 1-10.  after selection 
is made, the onChange event will fire and write however many text inputs 
on the screen using the innerHTML property.

my problem is that since javascript changes the screen at runtime, i 
can't use <html:input> to capture the text from the form because it 
isn't being interpreted by struts.  if the javascript uses the standard 
<input type="text"> tags, it seems like my actionform doesn't get 
populated with the data.

so, anyway to do this without having to submit the form after the user 
selects how many inputs they want?


---------------------------------------------------------------------
To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-user-help@jakarta.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-user-help@jakarta.apache.org