Click to See Complete Forum and Search --> : dynamically adding a read only attribute in a JSP tag


Cipherous
July 26th, 2005, 12:41 PM
Hey all

I am new to JSP and I would like to know (or if you guys could point me in a direction) on adding attributes to a tag dynamically with JSP

for example

I have this textinput field that takes in text

I just want to lock the textinput field when the user enters in "LOCKED", so in other words

when the textinput field gets the value of "LOCKED", the textinput field should be readonly or disabled.


Can anybody help me?

thanks!

Dr. Script
July 26th, 2005, 01:17 PM
JavaScript, or JavaServerPages? They are totally different. If you want to use JavaScript, you can use something like:<input type="text" id="txt" onkeyup="if(this.value.toUpperCase()=='LOCKED') this.setAttribute('readonly','readonly')">If you want only LOCKED and not LOcKeD, then remove the blue text in the code

Cipherous
July 26th, 2005, 05:56 PM
hey Dr.Script

I was actually referring to JSP. Could I incorporate the java script in JSP?

thanks for the reply

Dr. Script
July 26th, 2005, 06:06 PM
JSP is server coding. It cannot handle what you need, as far as I am aware. What you need is a client side language, which is what JavaScript is for. JSP could only handle it, for example (as far as I know), iuf after every letter the field is submitted with its value, and if the value is locked, then it could add the readonly attribute.

The code I provied will work in a .jsp page. However, since it is not JSP code, it can work equally as well on a .php, .html, .asp, etc ...

Cipherous
July 27th, 2005, 11:12 AM
thanks alot man!