You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Ju...@t-systems.com on 2003/06/03 14:53:26 UTC
JavaScript and text field
Hi,
I have some problems to access a text field.
I have this JSP code:
<html:form action="criteria.do" method="post" onsubmit="javascript:check()">
<html:text property="item" size="40" />....
And want to access the value of the item field:
function check(){
var inputvalue = document.all.item.value;
alert(inputvalue);
var inputvalue = document.forms[0].item.value;
alert(inputvalue);
}
No of these variant runs. In an another application I have the 2 solution and it works. Are there any depedencies between struts and JS?
Juraj
---------------------------------------------------------------------
To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-user-help@jakarta.apache.org
Re: JavaScript and text field
Posted by Sergey Smirnov <si...@exadel.com>.
Try the folowing:
<html:form action="criteria.do" method="post" onsubmit="return check(this)">
<html:text property="item" size="40" />....
....
function check(formId){
var inputvalue = formId.item.value;
alert(inputvalue);
return true;
}
Regards,
Sergey Smirnov
-------------------------------------
Exadel Struts Studio - IDE for Struts
http://www.exadel.com/strutsStudio
-------------------------------------
----- Original Message -----
From: <Ju...@t-systems.com>
To: <st...@jakarta.apache.org>
Sent: Tuesday, June 03, 2003 5:53 AM
Subject: JavaScript and text field
> Hi,
>
> I have some problems to access a text field.
>
> I have this JSP code:
>
> <html:form action="criteria.do" method="post"
onsubmit="javascript:check()">
> <html:text property="item" size="40" />....
>
> And want to access the value of the item field:
>
> function check(){
> var inputvalue = document.all.item.value;
> alert(inputvalue);
> var inputvalue = document.forms[0].item.value;
> alert(inputvalue);
> }
>
> No of these variant runs. In an another application I have the 2 solution
and it works. Are there any depedencies between struts and JS?
>
> Juraj
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: struts-user-help@jakarta.apache.org
>
---------------------------------------------------------------------
To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-user-help@jakarta.apache.org
Re: JavaScript and text field
Posted by Jeff Kyser <kt...@comcast.net>.
well, your check() function ought to return a boolean for starters.
function check() {
if (tests fail)
return false;
else
return true;
}
then,
onsubmit = "return check()"
-jeff
On Tuesday, June 3, 2003, at 07:53 AM, Juraj.Lenharcik@t-systems.com
wrote:
> Hi,
>
> I have some problems to access a text field.
>
> I have this JSP code:
>
> <html:form action="criteria.do" method="post"
> onsubmit="javascript:check()">
> <html:text property="item" size="40" />....
>
> And want to access the value of the item field:
>
> function check(){
> var inputvalue = document.all.item.value;
> alert(inputvalue);
> var inputvalue = document.forms[0].item.value;
> alert(inputvalue);
> }
>
> No of these variant runs. In an another application I have the 2
> solution and it works. Are there any depedencies between struts and > JS?
>
> Juraj
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: struts-user-help@jakarta.apache.org
>
---------------------------------------------------------------------
To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-user-help@jakarta.apache.org
RE: JavaScript and text field
Posted by Mike Jasnowski <mj...@bea.com>.
I would check the HTML source and see what the "Name" attribute for the
textfield you are trying to access is set to.
-----Original Message-----
From: Juraj.Lenharcik@t-systems.com
[mailto:Juraj.Lenharcik@t-systems.com]
Sent: Tuesday, June 03, 2003 8:53 AM
To: struts-user@jakarta.apache.org
Subject: JavaScript and text field
Hi,
I have some problems to access a text field.
I have this JSP code:
<html:form action="criteria.do" method="post" onsubmit="javascript:check()">
<html:text property="item" size="40" />....
And want to access the value of the item field:
function check(){
var inputvalue = document.all.item.value;
alert(inputvalue);
var inputvalue = document.forms[0].item.value;
alert(inputvalue);
}
No of these variant runs. In an another application I have the 2 solution
and it works. Are there any depedencies between struts and JS?
Juraj
---------------------------------------------------------------------
To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-user-help@jakarta.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-user-help@jakarta.apache.org