Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to accept <input ... name="myname[]" /> ??

Status
Not open for further replies.

gerrygerry

Technical User
Jul 19, 2001
500
0
0
US
Hi everyone-

I'm just really getting into JSP's... I come from a strong PHP background. I know in PHP you can accept arrays from forms... I wonder if there is a way in Java? Here's an example of the sort of form I'd like to b able to use...

Code:
-[myForm.htm]-
Code:
...
<form action=&quot;myJSP.jsp&quot; method=&quot;post&quot;>
 <input type=&quot;checkbox&quot; name=&quot;field[]&quot; value=&quot;1&quot; />
 <input type=&quot;checkbox&quot; name=&quot;field[]&quot; value=&quot;2&quot; />
 <input type=&quot;checkbox&quot; name=&quot;field[]&quot; value=&quot;3&quot; />
 <input type=&quot;submit&quot; />
</form>
...
In PHP, $field would be an array... right off the bat. In JSP, is there some sort of type-casting I can do?? Something like
Code:
Hashtable myFields = (Hashtable) request.getParameter(&quot;field&quot;);
??

I'm trying to put together a hotmail style &quot;delete row where checked&quot; interface... but I need to be able to set up my JSP to accept any number of inputs... is that clear? Can someone make some recommendations?

Thanks in advance! -gerrygerry

&quot;I'm doin' a one-nighter for bitin' Ed the mail man... the guy was tryin' to cast a spell on me... like a wizard or something.&quot;
&quot;Are you sure about that?&quot;
&quot;I dunno... maybe he was just wavin' [wavey]...&quot;
 
Code:
java.lang.String[] javax.servlet.ServletRequest.getParameterValues(java.lang.String);

-pete
 
hmmm... I feel like a complete moron now. Thanks pete! :p -gerrygerry

&quot;I'm doin' a one-nighter for bitin' Ed the mail man... the guy was tryin' to cast a spell on me... like a wizard or something.&quot;
&quot;Are you sure about that?&quot;
&quot;I dunno... maybe he was just wavin' [wavey]...&quot;
 
>> I feel like a complete moron now.

I usually feel that way!

-pete
 
hmmmm... ok.. i feel even dumber now :'(

could you just show me a quick example of how I would display all the submitted values?? for example, suppose they check the first and the third box (in my original example form).... how would I display the 1 and the 3 ??

thanks for your patience pete :-D -gerrygerry

&quot;I'm doin' a one-nighter for bitin' Ed the mail man... the guy was tryin' to cast a spell on me... like a wizard or something.&quot;
&quot;Are you sure about that?&quot;
&quot;I dunno... maybe he was just wavin' [wavey]...&quot;
 
as soon as I posted that, I figured it out... first thing tomorrow morning, I'm going out and buying a helmet. :p

Thanks for you help... :-D -gerrygerry

&quot;I'm doin' a one-nighter for bitin' Ed the mail man... the guy was tryin' to cast a spell on me... like a wizard or something.&quot;
&quot;Are you sure about that?&quot;
&quot;I dunno... maybe he was just wavin' [wavey]...&quot;
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top