You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Ding Lei <di...@ipanel.cn> on 2004/07/22 05:48:45 UTC
Accessing index properties in javascript validator
Hi list,
Some JSP pages uses Strut's indexed properties, like:
<html:file property="uploadData[0]"/>
And it could be accessed by the corresponding Action correctly through
a customized Form.
The problem is that I would like to add javascript validation before
the user submits the form to check if the file box is not null & valid. But
JS code doesn't seem to be able to access variables with braces.
Any ideas? Thanks in advance.
--
Layman <di...@ipanel.cn> Ext: 8059
Chivalry, Schmivalry!
Roger the thief has a
method he uses for
sneaky attacks:
Folks who are reading are
Characteristically
Always Forgetting to
Guard their own bac ...
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org
Re: Accessing index properties in javascript validator
Posted by atta-ur rehman <at...@gmail.com>.
Thanks Mark. I can see this is definitely better way of doing it!
ATTA
On Fri, 23 Jul 2004 11:40:18 +0200, Mark Lowe <ma...@boxstuff.com> wrote:
> Similarly but more compatible with older browsers.
>
> total = ${fn:length(theForm.properties)};
> form = document.forms["theForm"];
> for(i = 0;i < total;i++) {
> target = "property["+ i +"]";
> element = form.elements[target];
> alert(element.name +"="+ element.value);
> }
>
> Mark
>
>
>
>
> On 23 Jul 2004, at 02:09, atta-ur rehman wrote:
>
> > hello,
> >
> > this is how i've done it:
> >
> > textbox = document.getElementById("block[0]");
> > if (textbox.value ????)
> >
> >
> > so basically you use document.getElementById("property[0]") to get the
> > reference of html elment and then use .value or any other stuff on
> > this element.
> >
> > hope this helps!
> >
> > ATTA
> >
> >
> >
> > On Thu, 22 Jul 2004 11:48:45 +0800, Ding Lei <di...@ipanel.cn> wrote:
> >> Hi list,
> >> Some JSP pages uses Strut's indexed properties, like:
> >> <html:file property="uploadData[0]"/>
> >> And it could be accessed by the corresponding Action correctly
> >> through
> >> a customized Form.
> >> The problem is that I would like to add javascript validation before
> >> the user submits the form to check if the file box is not null &
> >> valid. But
> >> JS code doesn't seem to be able to access variables with braces.
> >> Any ideas? Thanks in advance.
> >>
> >> --
> >> Layman <di...@ipanel.cn> Ext: 8059
> >>
> >> Chivalry, Schmivalry!
> >> Roger the thief has a
> >> method he uses for
> >> sneaky attacks:
> >> Folks who are reading are
> >> Characteristically
> >> Always Forgetting to
> >> Guard their own bac ...
> >>
> >> ---------------------------------------------------------------------
> >> 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
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org
Re: Accessing index properties in javascript validator
Posted by Mark Lowe <ma...@boxstuff.com>.
Similarly but more compatible with older browsers.
total = ${fn:length(theForm.properties)};
form = document.forms["theForm"];
for(i = 0;i < total;i++) {
target = "property["+ i +"]";
element = form.elements[target];
alert(element.name +"="+ element.value);
}
Mark
On 23 Jul 2004, at 02:09, atta-ur rehman wrote:
> hello,
>
> this is how i've done it:
>
> textbox = document.getElementById("block[0]");
> if (textbox.value ????)
>
>
> so basically you use document.getElementById("property[0]") to get the
> reference of html elment and then use .value or any other stuff on
> this element.
>
> hope this helps!
>
> ATTA
>
>
>
> On Thu, 22 Jul 2004 11:48:45 +0800, Ding Lei <di...@ipanel.cn> wrote:
>> Hi list,
>> Some JSP pages uses Strut's indexed properties, like:
>> <html:file property="uploadData[0]"/>
>> And it could be accessed by the corresponding Action correctly
>> through
>> a customized Form.
>> The problem is that I would like to add javascript validation before
>> the user submits the form to check if the file box is not null &
>> valid. But
>> JS code doesn't seem to be able to access variables with braces.
>> Any ideas? Thanks in advance.
>>
>> --
>> Layman <di...@ipanel.cn> Ext: 8059
>>
>> Chivalry, Schmivalry!
>> Roger the thief has a
>> method he uses for
>> sneaky attacks:
>> Folks who are reading are
>> Characteristically
>> Always Forgetting to
>> Guard their own bac ...
>>
>> ---------------------------------------------------------------------
>> 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: Accessing index properties in javascript validator
Posted by atta-ur rehman <at...@gmail.com>.
hello,
this is how i've done it:
textbox = document.getElementById("block[0]");
if (textbox.value ????)
so basically you use document.getElementById("property[0]") to get the
reference of html elment and then use .value or any other stuff on
this element.
hope this helps!
ATTA
On Thu, 22 Jul 2004 11:48:45 +0800, Ding Lei <di...@ipanel.cn> wrote:
> Hi list,
> Some JSP pages uses Strut's indexed properties, like:
> <html:file property="uploadData[0]"/>
> And it could be accessed by the corresponding Action correctly through
> a customized Form.
> The problem is that I would like to add javascript validation before
> the user submits the form to check if the file box is not null & valid. But
> JS code doesn't seem to be able to access variables with braces.
> Any ideas? Thanks in advance.
>
> --
> Layman <di...@ipanel.cn> Ext: 8059
>
> Chivalry, Schmivalry!
> Roger the thief has a
> method he uses for
> sneaky attacks:
> Folks who are reading are
> Characteristically
> Always Forgetting to
> Guard their own bac ...
>
> ---------------------------------------------------------------------
> 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