0
  1. I have a javascript function updateHiddenField(value) that gets a value as parameter and then sets this value as the value of a hidden field.

  2. I have a JavaBean flight with parameters id and flightNo.

Problem: How can I pass the parameter id of JavaBean flight to the js function updateHiddenField(value) when using <html:link> tag(struts)?

<html:link href="javascript:updateHiddenField(idToPassHere)"><bean:write name="flight" property="flightNo"/></html:link>

Thanks Umar

2 Answers 2

1

You don't seem to be gaining anything by using <html:link> over <a> - so that would be the easiest change:

<a href="javascript:updateHiddenField(<bean:write name="flight" property="id"/>)"> <bean:write name="flight" property="flightNo"/> </a>

More generally I would suggest you add event listeners to your DOM objects, rather than mixing markup & functionality.

Sign up to request clarification or add additional context in comments.

Comments

0
<html:link href="javascript:updateHiddenField(<s:property value="id"/>)"><bean:write name="flight" property="flightNo"/></html:link>

Assuming your taglib import is <% @taglib prefix="s" uri="/struts-tags" %>

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.