Mark,

Thanks.... that wasn't a long wait!

Anyway....I think you're assuming I'm hardcoding this...I think. 

I am using the nested tags from Struts and, specifically, the 
nested:iterate tag. I'm not sure if I'm being presumptuous, but are you 
taking this into account? The tmpIndex is the actual iteration index that 
the tag uses to generate values from the ArrayList...usually good for 
building things in tables.

The trick I'm trying to solve is putting together this statement in a form 
javascript will accept it inside the nested:iterate tag.
This value is generated by the tag and can be obtained from the tmpIndex.  
 
                                                      I
                                                     V
document.forms[0].elements['eventList[0].targetDate'
document.forms[0].elements['eventList[1].targetDate'
document.forms[0].elements['eventList[2].targetDate'
.....

Thanks very much for the help. I hope we're on the same page.






Mark Lowe <[EMAIL PROTECTED]>
05/28/2003 06:19 PM
Please respond to "Struts Users Mailing List"

 
        To:     "Struts Users Mailing List" <[EMAIL PROTECTED]>
        cc: 
        Subject:        Re: javascript nested:iterate property reference


Sorry it took me a while to get back to you..

I reduce things down to this.. whats this mystrious tempIndex ? does 
this help.. i strip out the calender thingy. You need to know how to 
drill to form elements that are generated as indexed properties, in 
javascript. Any way does this help?

<form name="marksForm">
<input type="text" name="eventList[0].targetDate" value="Mellow 
world!!">
<input type="text" name="eventList[1].targetDate" value="Mellow world 
2!!">
</form>
<a href="javascript:void(0)" 
onclick="alert(document.forms[0].elements['eventList[0].targetDate'].val 
ue)">hit me!!</a>
<a href="javascript:void(0)" 
onclick="alert(document.forms[0].elements['eventList[1].targetDate'].val 
ue)">hit me 2!!</a>




On Wednesday, May 28, 2003, at 20:02 Europe/London, 
[EMAIL PROTECTED] wrote:

> Mark (et al),
> Here is the rendered html output from the jsp.
> I don't think there are any inconsistencies, but please give me more
> detail if you see something. This works fine when it's not in a
> nested:iterate loop. I just need to get a document object reference 
> that
> includes the resolved index and be able to pass it to the javascript
> function.
>
> I have to believe someone out there has done something similar and is 
> as
> little expert in mixing javascript and struts as I am.
>
> Thanks for the quick response, Joe
>
>                 <td><font size="-1" face="Arial, Helvetica, 
> sans-serif">
>                 <script language='JavaScript'>var cal1 = new
> CalendarPopup();
>                 cal1.setReturnFunction('showDate0');
>                 cal1.offsetX=2;
>                 function showDate0(y,m,d)
>                 {document.forms[0].elements['targetDate'].value = m + 
> "-"
> + d + "-" + y;}
>                 myVar2 = "document.forms[0].targetDate [" + tmpIndex +
> "]";
>                 </script>
>                         <input type="text" 
> name="eventList[0].targetDate"
> value="05-31-2003">  </font>
>                 <a HREF="#"
> onClick="cal1.select(document.forms[0].targetDate[tmpIndex],'anchor1',' 
> MM/dd/yyyy');
> return false;"                          NAME="anchor1" ID="anchor1">
>                         <img src="image/cal.gif" width="18" height="18"
> border="0"> (m-d-yyyy)
>                 </a>
>
>                 </td>
>
>
>
>
> Mark Lowe <[EMAIL PROTECTED]>
> 05/28/2003 02:50 PM
> Please respond to "Struts Users Mailing List"
>
>
>         To:     "Struts Users Mailing List" 
> <[EMAIL PROTECTED]>
>         cc:
>         Subject:        Re: javascript nested:iterate property 
> reference
>
>
> Could be more javascript than tag-libs..
>
> You've a few inconsistancies in approach at first glance.. targetDate
> looks like it should be a variable not a string literal.. Can you paste
> the code that arrives to the web browser (i.e. without the struts 
> tags)?
>
>
>
> On Wednesday, May 28, 2003, at 19:34 Europe/London,
> [EMAIL PROTECTED] wrote:
>
>> I'm trying to use Matt Kruse's javascript calendar popup
>> (http://www.mattkruse.com/javascript/calendarpopup/) inside a
>> nested:iterate. This is likely a javascript question, but I would
>> appreciate any help.... and it may help others save looking through 
>> the
>> archives for the 8+ hours I've spent already trying to find this.
>>
>> The call to "cal1" on the "onselect" fails. I've tried every
>> permutation I
>> could think of. I've tried putting the document element reference in a
>> variable and calling it that way, but it seems the tmpIndex will not
>> resolve. This would seem to be a generalized problem for referencing
>> any
>> form property in a javascript function call involving nested:iterate
>> elements. Once again, please, any help vastly appreciated.
>>
>> Here is the jsp excerpt:
>> <<<<<
>> <nested:iterate property="eventList" id="ev" indexId="evIdx">
>>         <table width="924" border="4" cellpadding="0" cellspacing="0">
>>          <bean:define id="tmpIndex" value="<%=
>> String.valueOf(evIdx.intValue())%>"/>
>>                 <td><font size="-1" face="Arial, Helvetica,
>> sans-serif">
>>                         <script language='JavaScript'>var cal1 = new
>> CalendarPopup();
>>                         cal1.setReturnFunction('showDate0');
>>                         cal1.offsetX=2;
>>                         function showDate0(y,m,d)
>>
>> {document.forms[0].elements['targetDate'].value =
>> m + "-" + d + "-" + y;}
>>                         myVar2 = "document.forms[0].targetDate [" +
>> tmpIndex + "]";
>>                         </script>
>>                 <nested:text property="targetDate" />  </font>
>>                 <a HREF="#"
>> onClick="cal1.select(document.forms[0].targetDate[tmpIndex],'anchor1', 
>> '
>> MM/dd/yyyy');
>> return false;" NAME="anchor1" ID="anchor1">
>>                 <img src="image/cal.gif" width="18" height="18"
>> border="0"> (m-d-yyyy)
>>                 </a>
>>                 </td>
>>                 ......
>>>>>>>
>>
>>
>>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>
>
>
>
>
> = = = = = = = = = == = = = = = == = = = = = = = == = = = = = == = = = =
> This transmittal and any attachments may contain confidential, 
> privileged or sensitive information and is solely for the use of the 
> intended recipient. If you are not intended recipient, you are hereby 
> notified that you have received this transmittal and any such 
> attachments in error and any review, dissemination, distribution or 
> copying thereof is strictly prohibited. If you have received this 
> transmittal and any attachments in error please notify the sender and 
> immediately destroy the message and all its attachments. Any opinions 
> herein expressed may be those of the author and not necessarily of 
> Mizuho Corporate Bank, Ltd (the "Bank"). The Bank accepts no 
> responsibility for the accuracy or completeness of any information 
> herein contained.
> = = = = = = = = = == = = = = = == = = = = = = = == = = = = = == = = = =
>


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Reply via email to