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 Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Forms - select and text elements with same name?

Status
Not open for further replies.

vjh

Technical User
Dec 14, 2002
46
CA
Hi all,

I have a form that is dynamically populated and then further processed using jsp. In a couple of cases, I would like to supply a text area and a select menu, with the same name, so the user can either choose a value or enter a new one to search on.

The jsp code can then handle the decision of what kind of search to implement.

I've tried this, but the code only seems to recognize the first of the two elements.

Can this be done???

vj
 
Hi,

You can't have 2 elements with the same name, it will not work as intended.

Simply name both a different name, then to decide which route you want to go simply determin (using jsp) if the field has been filled out of not and then go from there.

Hope this helps!

Nate

mainframe.gif

 
Too bad, I feared as much. It would have made life much easier!

Thanks for the quick response.

vj [snail]
 
Wullie

Yours is a more hopeful response... If they are comma delimited, how would I deal with them?

Here's an example of the html code:

<td>
<input type = 'text' size=5 name = 'HT'>
</td>

<td>
<select width=200 name = 'HT'>
<option value = ''>*</option>
<option value = '10-120'>10-120</option>
<option value = '10-150'>10-150</option>
</select>
</td>

It seems from what I get that only the text area sends data.

... V
 
Hi mate,

What method are you using to submit the form?

It will depend on the language that you use whether I can help you or not.

Look at the following link for a coldfusion example:


Hope this helps

Wullie


The pessimist complains about the wind. The optimist expects it to change.
The leader adjusts the sails. - John Maxwell
 
I'm using jsp - Here's the post method. 'q' is a list of ids the result of an earlier query, which is passed to a bean which generate the HT options.


<form action=&quot;search.jsp?q=12,33,44,55&quot; method = &quot;post&quot;>

When I enter a number in the text area, the HT variable gets set on the receiving page. When I choose from the dropdown, I don't get the variable.

 
Have both the drop-down and the text area on your page, with different names. Also have a hidden field with yet another hidden name. As part of the validation routine - set the value of the hidden field to either the text value, or the drop-down value.
 
Thanks for your suggestion dwarf,
How would I implement this? Actually - this might better be asked in the Javascript forum. Look for my follow-up question there!

v
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top