• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

set text filed values based on drop down selection

 
Ranch Hand
Posts: 189
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi ranchers,

I have a drop down with two values : 'nos.' and 'kg' and i have 10 text fields.

By default the value of the text field is 'nos.' .
If i select 'kg' in the drop down all the text fields should change to kg.

Here is my code:

<td>
<html:select property="UOM" onchange="changeValue(this.value);">
<html:option value="nos."></html:option>
<html:option value="kg"></html:option>
</html:select>
</td>

<logic:iterate id="lines" name="purchaseOrderBeanForm" property="lines">
<tr>
<td><%=i %></td>
<td align="center"><html:text indexed="true" name="lines" property="POD"/></td>
<td align="center"><html:text indexed="true" name="lines" property="PON"/></td>
<td><html:text indexed="true" name="lines" property="POQ" size="6"/></td>
<td></td>
<td><html:text indexed="true" name="lines" property="UOM1" size="4" value="nos."/></td>
</tr>
<% i++; %>
</logic:iterate>

I am using DynaActionForm.

the entry in struts-config is as follows:
<form-bean name="purchaseOrderBeanForm" type="org.apache.struts.action.DynaActionForm">
<form-property name="lines" type="ActionForm.AddPOBean[]" size="10" />
<form-property name="selected" type="java.lang.String" />
<form-property name="arrCustID" type="java.util.ArrayList" />
<form-property name="UOM" type="java.lang.String" />
<form-property name="POB2B" type="java.lang.String" />
<form-property name="POTX" type="java.lang.String" />
<form-property name="PONO" type="java.lang.String" />
</form-bean>

This is what i tried:
function changeValue(value)
{
var weight = value;
var i = 0;
alert(weight);
alert(document.purchaseOrderBeanForm.lines[0].UOM1.value);
document.purchaseOrderBeanForm.lines[1].UOM1.value = "kg";

}

Please help me out!!!

Thanks
 
Sheriff
Posts: 67746
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Please be sure to ask Struts questions in the Struts forum. I have moved this post there for you.
 
Author
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Really, it's a JavaScript question.

You neglect to actually mention *what* doesn't work, just saying "it doesn't work" is not helpful: TellTheDetails.

That said, if you're trying to change 10 text fields, it'd make sense to have the JavaScript change 10 text fields--yours changes only a single text field, which is around 9 short. Perhaps a loop, or in any reasonable JavaScript library, a selector with a function.
 
World domination requires a hollowed out volcano with good submarine access. Tiny ads are optional.
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic