Reputation: 2952
I have two elements with name price1
[BTW I know that having duplicate IDs is against standards, is this the same with NAME?]
<TR CLASS="Blocks" id="p_priceKILO" style="display: none ;">
<TD>Price:</TD>
<TD><INPUT TYPE="text" name="price1">$/kilo</TD>
</TR>
<TR CLASS="Blocks" id="p_pricePOUND" style="display: none ;">
<TD>Price:</TD>
<TD><INPUT TYPE="text" name="price1">$/pound</TD>
</TR>
Only one of these rows will be visible at one time (using javascript)
I use the following java code to retrieve price1
public PricePosition(HttpServletRequest request) {
this.price1=StringFunctions.StringToDouble(request
.getParameter("PRICE1"));
...
Is there any neat way to retrieve only the visible element?
I have a workaround - calling them price1a
and price1b
and retrieving the correct one based on my knowledge of which one is visible, but I wondered if there was another way.
Upvotes: 0
Views: 69
Reputation: 48807
You'll have to use JS again: when displaying a row, rename the inner corresponding input to displayedPrice
for example, and get this parameter server-side.
When hiding a row, don't forget to rename it back.
Upvotes: 2