How to use javascript to include struts html tag?

冷暖自知 提交于 2019-12-13 03:04:23

问题


I have a check box and a text box. I have used struts tags and

Now i need to validate that if the check box is checked, i should gray out (disable) the text box. If it is unchecked the text box shold take phone numbers.

I did lik this, i called a java script on click of check box and did a innerHtml based on wheather checkbox ix checked or not.

var status_check=document.getElementById("line1Checked").checked; if(status_check==true){ document.getElementById("line1").readonly="true"; } else{ document.getElementById("line1").readonly="false"; }

I shud make the text box readonly if the check box is selected. This is how the text box is defiened,

Please suggest..


回答1:


OK - now it's easier to understand - thanks. 1. make sure that use the styleId - attribute within your for the input-field. To set this input field readonly your javascript code should do:

document.getElementById("line1").setAttribute("readonly","true");

hope that helps




回答2:


HI DJ,

do you get an error message for your 2nd javascript snippset? Also could post a little bit more code. From these few lines it's hard to see if text will be " or undefined. Anyway if you disable the textarea take into account that the input may not be posted.



来源:https://stackoverflow.com/questions/2475296/how-to-use-javascript-to-include-struts-html-tag

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!