Ok, I tried the following which was using a input tag as normal:
<input type="text" name="<%="value["+index.intValue()+"].value"%>" size="20"
onblur="calculate(this.value,
'<bean:write name="benefit" property="benMaxRange"/>',
'<bean:write name="benefit" property="benMinRange"/>',
'<bean:write name="benefit" property="benRange"/>',
'<bean:write name="benefit" property="label"/>')"/>
The this.value parameter passes the correct value to my javascript function
and I can submit it to the action class. However I now run into a issue
when I try to load the data back into the form as I have lost all my values.
They come back from the DB ok but are lost in creating the tag. I have also
tried it with value="" in the input tag but then this does not submit the
values correctly. So I had to take the value="" out to get it to submit
correctly.
If I had <html:text property="<%="benefits["+index.intValue()+"].value"%>"
size="20" onblur="<%=jsFunction%>"/> then this brings back the correct value
to display however then I am back at the problem I started with which is how
to pass the value of the element to the JS function.
Is there anyway I can pass <bean:write name="benefit"
property="benMaxRange"/> as a parameter to a function into the <html:text
tag onblur event> of struts without using the <bean define tag>
-----Original Message-----
From: Shoukat, Faisal
Sent: 14 June 2006 11:51
To: 'Struts Users Mailing List'
Subject: evaluating list backed action form value in javascript
Hi,
I am using a list backed action form and need some advice on how to get the
value from the html:text box so I can do some logic with it in a javascript
function.
In my case I have the following:
<html:text property="<%="benefits["+index.intValue()+"].value"%>" size="20"
onblur="<%=jsFunction%>"/>
My jsFunction is as follows:
<bean:define id="jsFunction">
javascript:calculate('<%="benefits[" + index.intValue() + "].value"%>',
'<bean:write name="benefit" property="benMaxRange"/>',
'<bean:write name="benefit" property="benMinRange"/>',
'<bean:write name="benefit" property="benRange"/>',
'<bean:write name="benefit" property="label"/>')
</bean:define>
The problem I am having is how to get the actual value entered in the text
box and pass this into the function (i.e 12000 instead of what is actually
being sent which is <%="benefits[0].value"%>). So it would be the parameter
<%="benefits[" + index.intValue() + "].value"%> of the calculate function.
Thanks in adavce
Faisal
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]