I'm having trouble trying to access textfield through javascript by using a string of it name to reference the object. For example
- function toggle(num){
-
document.form.paragraph_1.readOnly=!document.form.paragraph_1.readOnly;
-
}
-
When clicking on a link which calls this function, it will toggle a paragraph's readOnly ability. However I'm hardcoding in paragraph_1 as the name of the textfield. I want to be able to pass the id of the paragraph in the num parameter and toggle its related paragraph.
ie.
- document.form."paragraph_"+num.readOnly=!document.form."paragraph_"+num.readOnly;
where I'm contructing the name from the string
I cannot cycle through the elements[] array because I'm using AJAX to dyamically reorded the paragraph text fields, so I believe that would mess with the order of the elements. I think I am limitted to retrieving the object by its name.
Any suggestion?
Greatly appreciate it.