You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Michael Rush <ru...@onstation.com> on 2004/11/03 19:47:05 UTC
javascript question
I've got a form that's using nested forms, with the following type of
layout..
[radio] option 1
[text] value 1
[text] value 2
[radio] option 2
[text] value 1
[text] value 2
[radio] option 3
[text] value 1
[text] value 2
Each of the groups is a nested form, so the form element names are in
the form of nestedform.property. I would like to add an onclick to the
text fields so that the radio button for that group is selected if
someone starts entering text in the value1 or value 2 fields. The
problem is that the field names have a period in them, so javascript is
thinking there's another object in the hierarchy. Is there a way to
escape or quote the name of the field? Or another way to identify the
field?
Thanks,
Michael
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org
Re: javascript question
Posted by Mark Miller <Ma...@nulli.com>.
This is where the HTML styleId attribute comes in handy in combination
with indexId of the LOGIC Iterator.
<logic:iterate id="objectName" indexId="ctr" name="parcel"
property="parcelObj">
<html:text styleId="my_${ctr}" property="parcelLists[${ctr}].appDn"/>
</logic:iterate>
This sets up unique object identifiers by id and then you can get at
them by reference in your javascript:
var ns4 = document.layers? true : false;
var ie = document.all? true : false;
var dom = document.getElementById && !document.all ? true : false;
function getObject(id) {
if (dom)
return document.getElementById(id);
else if (ie)
return document.all[id];
else if (ns4)
return document.layers[id];
}
HTH,
Mark
Michael Rush wrote:
> I've got a form that's using nested forms, with the following type of
> layout..
>
> [radio] option 1
> [text] value 1
> [text] value 2
>
> [radio] option 2
> [text] value 1
> [text] value 2
>
> [radio] option 3
> [text] value 1
> [text] value 2
>
> Each of the groups is a nested form, so the form element names are in
> the form of nestedform.property. I would like to add an onclick to the
> text fields so that the radio button for that group is selected if
> someone starts entering text in the value1 or value 2 fields. The
> problem is that the field names have a period in them, so javascript is
> thinking there's another object in the hierarchy. Is there a way to
> escape or quote the name of the field? Or another way to identify the
> field?
>
> Thanks,
> Michael
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
>
--
Mark Miller
Nulli Secundus Inc.
403.270.0657 ext.30
403.512.4082 mobile
mark@nulli.com
http://www.nulli.com
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org
Re: javascript question
Posted by Michael Rush <ru...@onstation.com>.
Excellent. I figured there was something like this. Your solution
worked nicely. For any others that may be interested, here's an example
of what I used:
onclick="this.form['parent.nestedname'][2].checked='true'"
Thanks,
Michael
On Nov 3, 2004, at 10:51 AM, Jason King wrote:
> document.formname["parent.nestedname"] will reference an element in
> the form formname which has a period in it's name.
> Michael Rush wrote:
>
>> I've got a form that's using nested forms, with the following type of
>> layout..
>>
>> [radio] option 1
>> [text] value 1
>> [text] value 2
>>
>> [radio] option 2
>> [text] value 1
>> [text] value 2
>>
>> [radio] option 3
>> [text] value 1
>> [text] value 2
>>
>> Each of the groups is a nested form, so the form element names are in
>> the form of nestedform.property. I would like to add an onclick to
>> the text fields so that the radio button for that group is selected
>> if someone starts entering text in the value1 or value 2 fields. The
>> problem is that the field names have a period in them, so javascript
>> is thinking there's another object in the hierarchy. Is there a way
>> to escape or quote the name of the field? Or another way to identify
>> the field?
>>
>> Thanks,
>> Michael
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
>> For additional commands, e-mail: user-help@struts.apache.org
>>
>>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
>
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org
Re: javascript question
Posted by Jason King <jh...@airmail.net>.
document.formname["parent.nestedname"] will reference an element in the
form formname which has a period in it's name.
Michael Rush wrote:
> I've got a form that's using nested forms, with the following type of
> layout..
>
> [radio] option 1
> [text] value 1
> [text] value 2
>
> [radio] option 2
> [text] value 1
> [text] value 2
>
> [radio] option 3
> [text] value 1
> [text] value 2
>
> Each of the groups is a nested form, so the form element names are in
> the form of nestedform.property. I would like to add an onclick to the
> text fields so that the radio button for that group is selected if
> someone starts entering text in the value1 or value 2 fields. The
> problem is that the field names have a period in them, so javascript
> is thinking there's another object in the hierarchy. Is there a way to
> escape or quote the name of the field? Or another way to identify the
> field?
>
> Thanks,
> Michael
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org