Click to See Complete Forum and Search --> : Embeding Java Script in SERVLETS to Blurr/inactvate INPUT fields of a table.


prince
04-23-2005, 11:41 AM
Hi there.

I am displaying a page generated from a SERVLET it outputs a table with rows in it .. The constrain here is the table values are taken out of a vector and filled on the table columns.

Since to insert values from vector into table colums . The table columns are taken as INPUT fields and remains active on the page. Which need to be made inactive /Blurred after vector does its filling . Thus to stop user entering any value or to change the same.

In simple way I am looking for :

1) Embeding a java script in SERVLET to be called on columns to blurr them. HOW IT CAN BE ACHEIEVED?

Please send any such working example/reference or suggestion you have .Thanks!

Khalid Ali
04-23-2005, 07:40 PM
Here is the javascript that will do that for you, you will have to spend some time on escaping all of the qoutes and such to make it work from java.

<script type="text/javascript">
<!--
function init(){
var inputFields = document.getElementsByTagName("input");
if(inputFields!=null){
var len = inputFields.length;
for(var n=0;n<len;n++){
var field = inputFields[n];
if(field!=null && field.type!=null && field.type.toLowerCase()=="text"){
field.readOnly = true;
}
}
}
}
//-->
</script>
</head>

<body onload="init();">

ray326
04-23-2005, 11:17 PM
Problem #1 is that you should not be writing HTML with a servlet. The servlet should prepare Javabeans and pass them to a JSP to do the HTML.