Is it possible that we can alter the field attribute such as the class="required" or the set is hidden in the HTML using JAVA code?
-
1maybe... what have you tried?Marco Forberg– Marco Forberg05/27/2013 08:04:15Commented May 27, 2013 at 8:04
-
Please do not hesitate to post the codes you have tried.Subedi Kishor– Subedi Kishor05/27/2013 08:05:54Commented May 27, 2013 at 8:05
-
actually i dont have any idea at all how to do it. because i never alter HTML using from JAVA code.Chi– Chi05/27/2013 08:16:45Commented May 27, 2013 at 8:16
Add a comment
|
2 Answers
Is it possible? YES it is.
Is it JAVA? No, it isn't.
It is Javascript!
Just access your element through the DOM and change the className
property.
Example:
document.getElementById('idOfTheElementToChangeClass').className += "required"; //I use += because otherwise it would override all the other classes(if set)
-
which mean i cant alter it from a Java file?Chi– Chi05/27/2013 08:17:36Commented May 27, 2013 at 8:17
-
If you want to do it client-side then no, you can'tNiccolò Campolungo– Niccolò Campolungo05/27/2013 08:18:15Commented May 27, 2013 at 8:18
-
actually what i gonna do is to alter several JSP page. So, i think it is more easier if i can do the logic on a singgle JAVA file.Chi– Chi05/27/2013 08:18:51Commented May 27, 2013 at 8:18
-
This code must be added in the HTML file, it doesn't matter if it is
.php
,.jsp
or whatever, is the browser that reads it!Niccolò Campolungo– Niccolò Campolungo05/27/2013 08:19:47Commented May 27, 2013 at 8:19 -
1If I really understood what you want to do(and I'm not sure) then yes, you haveNiccolò Campolungo– Niccolò Campolungo05/27/2013 08:25:57Commented May 27, 2013 at 8:25
you cannot do it with java if it is a plain HTML page that you are using... you need to use java script in this case...
However, if you are using any dynamic UI technologies like GWT... then you have option to do it using JAVA..