?
Solved

JSP Field removal on fly

Posted on 2004-08-20
2
Medium Priority
?
272 Views
Last Modified: 2012-05-05
I have two textfields in a JSP page

I want to remove these fields BUT without touching the JSP.

There are 2 phase of this small project as mentioned below:

In first phase, remove the first text field. In the second remove the second text field.

I need to use JavaScript for hide and show the fields in the JSP

Here is a brief example :

<html>
<head>
      <title></title>
</head>

<body>
<P>Field 1: Remove this field in phase I using Javascript</P>
<P><INPUT name=FIELD1 value=""></P>
<P>Field 2: Remove this field in phase II using Javascript</P><INPUT
name=FIELD2 value="">


</body>
</html>

Please advise accordingly (a code snippet will be a lot help)

Thanks a lot
0
Comment
Question by:Java_Problem
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 2

Expert Comment

by:beermequik
ID: 11854211
<body>
<P>Field 1: Remove this field in phase I using Javascript</P>
<P><INPUT ID="FIELD1" name=FIELD1 value=""></P>
<P>Field 2: Remove this field in phase II using Javascript</P><INPUT ID="FIELD2"
name=FIELD2 value="">


</body>

<SCRIPT>
function hide(id){
    var elem = document.getElementById(id);
    elem.style.visibility = "hidden";
}
</SCRIPT>

use js to call hide("FIELD1") or hide("FIELD2");


0
 
LVL 21

Accepted Solution

by:
MogalManic earned 375 total points
ID: 11856181
1)label all of your html elements with 'id' attributes (i.e. <p id='fieldA'>...</p>)
2)Then in the javascript do the following
   aNode=document.getElementById('fieldA');  //Get the first field with ID=='fieldA'
   aNode.style.display='none';  //To Display again, use:display='block'
             OR
   aNodeList=document.getElementByName('fieldA');  //Get the list of fields with ID=='fieldA'
   for(i=0;i<aNodeList.length;i++) {
     aNodeList[i].style.display='none';  //To Display again, use:display='block'
   }


This has the advantage over setting the visibity in that the page will remove the space used by the hidden elements.
0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

A short article about problems I had with the new location API and permissions in Marshmallow
This article will show how Aten was able to supply easy management and control for Artear's video walls and wide range display configurations of their newsroom.
In this fourth video of the Xpdf series, we discuss and demonstrate the PDFinfo utility, which retrieves the contents of a PDF's Info Dictionary, as well as some other information, including the page count. We show how to isolate the page count in a…
Progress
Suggested Courses

770 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question