You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by "Shoukat, Faisal" <fa...@northgate-is.com> on 2006/05/04 13:02:28 UTC

calling js function with list backed form value

Hi,

I have a list backed action form and want to call a javascript function with
one of the parameters to the function being a value from the list backed
action form. 

My js function is as such:

<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 value I want substituted into the function is <%="benefits[" +
index.intValue() + "].value"%>

My input text tag is as such which calls the function:

<input type="text" name="<%="benefit["+index.intValue()+"].value"%>"
value="" size="20" onblur="<%=jsFunction%>"/>

Can anyone help with explaining how to get the value from the input text box
of the form and send it to the function. The text boxes name is dynamic thus
causes me problems.

The html source shows the following: benefit[0].value in the function and
not the actual value.

Thanks

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Re: [OT] calling js function with list backed form value

Posted by siva sajja <si...@gmail.com>.
Hi

Here you are using a normal input tag from html which has no knowledge of
any of the struts functionalities(mapped back properties). Use html:text
instead

Cheers,
Siva.

Shoukat, Faisal wrote:
>
> >Hi,
> >
> >I have a list backed action form and want to call a javascript function
> with
> >one of the parameters to the function being a value from the list backed
> >action form.
> >
> >My js function is as such:
> >
> ><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 value I want substituted into the function is <%="benefits[" +
> >index.intValue() + "].value"%>
> >
> >My input text tag is as such which calls the function:
> >
> ><input type="text" name="<%="benefit["+index.intValue()+"].value"%>"
> >value="" size="20" onblur="<%=jsFunction%>"/>
> >
> >Can anyone help with explaining how to get the value from the input text
> box
> >of the form and send it to the function. The text boxes name is dynamic
> thus
> >causes me problems.
> >
> >The html source shows the following: benefit[0].value in the function and
> >not the actual value.
> >
> >Thanks
> >
> >---------------------------------------------------------------------
> >To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> >For additional commands, e-mail: user-help@struts.apache.org
> >
> >
> >
>
>
> ------------------------------DISCLAIMER------------------------------
> This message is for the named person's use only. It may contain
> confidential, proprietary or legally privileged information. No
> confidentiality or privilege is waived or lost by any mistransmission.
>
> If you receive this message in error, please immediately delete it and
> all copies of it from your system, destroy any hard copies of it and
> notify the sender. You must not, directly or indirectly, use, disclose,
> distribute, print, or copy any part of this message if you are not the
> intended recipient.
>
> Lisle Technology Partners Pvt. Ltd. and any of its subsidiaries each
> reserve the right to monitor all e-mail communications through its
> networks.
>
> Any views expressed in this message are those of the
> individual sender, except where the message states otherwise and the
> sender is authorized to state them to be the views of any such entity.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
>
>

Re:[OT] calling js function with list backed form value

Posted by vijay venkataraman <vi...@ltp.soft.net>.
In your JS function can you add 'this' as one of the parameter. Then in 
your js function you can get the value from the element.
Like <input type="text" onclick="return someFunction(this)"/> which 
implies the element on which the event occured.
Note: I have never used <bean:xxx tags> and  don't know much about it.  
My thoughts.

Thanks,
Vijay Venkataraman

Shoukat, Faisal wrote:

>Hi,
>
>I have a list backed action form and want to call a javascript function with
>one of the parameters to the function being a value from the list backed
>action form. 
>
>My js function is as such:
>
><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 value I want substituted into the function is <%="benefits[" +
>index.intValue() + "].value"%>
>
>My input text tag is as such which calls the function:
>
><input type="text" name="<%="benefit["+index.intValue()+"].value"%>"
>value="" size="20" onblur="<%=jsFunction%>"/>
>
>Can anyone help with explaining how to get the value from the input text box
>of the form and send it to the function. The text boxes name is dynamic thus
>causes me problems.
>
>The html source shows the following: benefit[0].value in the function and
>not the actual value.
>
>Thanks
>
>---------------------------------------------------------------------
>To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
>For additional commands, e-mail: user-help@struts.apache.org
>
>  
>


------------------------------DISCLAIMER------------------------------
This message is for the named person's use only. It may contain 
confidential, proprietary or legally privileged information. No
confidentiality or privilege is waived or lost by any mistransmission. 

If you receive this message in error, please immediately delete it and 
all copies of it from your system, destroy any hard copies of it and 
notify the sender. You must not, directly or indirectly, use, disclose, 
distribute, print, or copy any part of this message if you are not the 
intended recipient. 

Lisle Technology Partners Pvt. Ltd. and any of its subsidiaries each 
reserve the right to monitor all e-mail communications through its 
networks. 

Any views expressed in this message are those of the 
individual sender, except where the message states otherwise and the 
sender is authorized to state them to be the views of any such entity.

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org