Subject: Re: links to javascript with index variables From: "Rob Breeds" <[EMAIL PROTECTED]> === Karen
That's more lines but it does avoid scriptlets so it must be a GOOD thing! Thanks for looking at this Rob "Prengaman.Karen" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED]... > Rob, > > I did something similar today. I went through a lot of the same steps as > you and here is what I finally came up with (using your code): > > <logic:iterate id="el" name="reallySimpleForm" property="names" indexId="i"> > <bean:define id="url1" value="javascript:subForm(document.forms[0],'del','" > /> > <bean:define id="url2" value="');" /> > Name: <bean:write name="el"/> <html:link href="<%= > url1+i+url2"><bean:message key="link.delete"/></html:link><BR> > </logic:iterate> > > I'm not sure if this is the best solution, but it's working. > > -Karen > > -----Original Message----- > From: Rob Breeds [mailto:[EMAIL PROTECTED]] > Sent: Thursday, November 15, 2001 3:53 PM > To: Struts Users Mailing List > Subject: Re: links to javascript with index variables > > > I then tried this, using a scriptlet to create the javascript first: > > <% String tryit = "javascript:subForm(document.forms[0],'del','"+i+"');"; > %> > Name: <bean:write name="el"/> <html:link href="<%= tryit %>"><bean:message > key="link.delete"/></html:link> > > and that works too! > > Now can someone clever please share with me how to do this elegantly > without reverting to scriptlets? > > Thanks! > > Rob > > > > > > Rob > > Breeds/UK/IBM@ To: "Struts Users Mailing List" > <[EMAIL PROTECTED]> > IBMGB cc: > > Subject: Re: links to > javascript with index variables > > 15/11/2001 > > 23:47 > > Please respond > > to "Struts > > Users Mailing > > List" > > > > > > > > > > And then I tried it without struts tags: > > <A HREF="javascript:subForm(document.forms[0],'del','<%= i.toString() > %>');">try this</A> > > and it works! Why doesn't it work when the same code is put into the Struts > <html:link href> attribute ? > > Rob > > > > > Rob > Breeds/UK/IBM@ To: "Struts Users Mailing > List" <[EMAIL PROTECTED]> > IBMGB cc: > Subject: Re: links to > javascript with index variables > 15/11/2001 > 23:39 > Please respond > to "Struts > Users Mailing > List" > > > > > > > > I tried this: > > <logic:iterate id="el" name="reallySimpleForm" property="names" indexId > ="i"> > Name: <bean:write name="el"/> <html:link href > ="javascript:subForm(document.forms[0],'del','<%= i.toString() > %>');"><bean:message key="link.delete"/></html:link><BR> > </logic:iterate> > > but that just generates links of: > javascript:subForm(document.forms[0],'del','<%= i.toString() %>'); > > instead of javascript:subForm(document.forms[0],'del','0'); > > How can I get scripting variables inside the html:link href attribute? > > Thanks > > Rob > > > > > Rob > Breeds/UK/IBM@ To: "Struts Users Mailing > List" <[EMAIL PROTECTED]> > IBMGB cc: > Subject: links to javascript > with index variables > 15/11/2001 > 22:58 > Please respond > to "Struts > Users Mailing > List" > > > > > > > In my ActionForm I have a collection of names which is added to > dynamically. If I want to give each name its own delete link I'm doing this > with iterate: > > <logic:iterate id="el" name="reallySimpleForm" property="names"> > Name: <bean:write name="el"/> <html:link href > ="javascript:subForm(document.forms[0],'del');"><bean:message key > ="link.delete"/></html:link><BR> > </logic:iterate> > > (where subForm is a JavaScript function to submit the form, and set an > action, of 'del' in this case) > > but how do I add an index value into the javascript call for the link? To > generate something like: > > <html:link href="javascript:subForm(document.forms[0],'del', 0) (last param > being the index) > <html:link href="javascript:subForm(document.forms[0],'del', 1) > <html:link href="javascript:subForm(document.forms[0],'del', 2) > . > . > . > > Is the only way to do this using scriptlets? > > Thanks > > Rob Breeds > > > > > -- > To unsubscribe, e-mail: < > mailto:[EMAIL PROTECTED]> > For additional commands, e-mail: < > mailto:[EMAIL PROTECTED]> > > > > > > -- > To unsubscribe, e-mail: < > mailto:[EMAIL PROTECTED]> > For additional commands, e-mail: < > mailto:[EMAIL PROTECTED]> > > > > > > -- > To unsubscribe, e-mail: < > mailto:[EMAIL PROTECTED]> > For additional commands, e-mail: < > mailto:[EMAIL PROTECTED]> > > > > > > -- > To unsubscribe, e-mail: > <mailto:[EMAIL PROTECTED]> > For additional commands, e-mail: > <mailto:[EMAIL PROTECTED]> > > -- > To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]> > For additional commands, e-mail: <mailto:[EMAIL PROTECTED]> > -- To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]> For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>