如何使用javascript包含struts html标签? [英] How to use javascript to include struts html tag?
问题描述
我有一个复选框和一个文本框. 我已经使用了struts标记和
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.
我确实喜欢这个,我在复选框的单击处调用了Java脚本,并检查了是否基于Wheater复选框ix的innerHtml.
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"; } 别的{ document.getElementById("line1").readonly ="false"; }
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,
请提出建议.
推荐答案
好-现在更容易理解-谢谢. 1.确保在输入字段中使用styleId-属性.要将此输入字段设置为只读,您的JavaScript代码应执行以下操作:
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");
希望有帮助
这篇关于如何使用javascript包含struts html标签?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!