English 中文(简体)
How to use javascript to include struts html tag?
原标题:

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..

最佳回答

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

问题回答

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.





相关问题
selected text in iframe

How to get a selected text inside a iframe. I my page i m having a iframe which is editable true. So how can i get the selected text in that iframe.

How to fire event handlers on the link using javascript

I would like to click a link in my page using javascript. I would like to Fire event handlers on the link without navigating. How can this be done? This has to work both in firefox and Internet ...

How to Add script codes before the </body> tag ASP.NET

Heres the problem, In Masterpage, the google analytics code were pasted before the end of body tag. In ASPX page, I need to generate a script (google addItem tracker) using codebehind ClientScript ...

Clipboard access using Javascript - sans Flash?

Is there a reliable way to access the client machine s clipboard using Javascript? I continue to run into permissions issues when attempting to do this. How does Google Docs do this? Do they use ...

javascript debugging question

I have a large javascript which I didn t write but I need to use it and I m slowely going trough it trying to figure out what does it do and how, I m using alert to print out what it does but now I ...

Parsing date like twitter

I ve made a little forum and I want parse the date on newest posts like twitter, you know "posted 40 minutes ago ","posted 1 hour ago"... What s the best way ? Thanx.

热门标签