struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Chen, Gin" <Gin.C...@NielsenMedia.com>
Subject RE: JavaScript and text field
Date Tue, 03 Jun 2003 14:29:23 GMT
function check()
{
	var inputvalue = document.getElementById("item").value;
	alert( inputvalue );
}

dont worry that it says get element by id. it actually checks both name and
id.
another way to do it is:

function check()
{
	var inputvalue = document.getElementsByName("item")[0].value;
	alert( inputvalue );
}

-Tim

-----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


Mime
View raw message